20081027

Sweet Dreams Security

As you may have noticed, for personal reasons, I'm not going to be posting here as regularly for a while. Don't worry, I'll return to regular posts soon.

This isn't really technology related, but it does appeal to my the wannabe-design-geek in me.

You know how on some walls, they put that broken glass stuff on the top so people can't really climb over it? Here's an attractive version of that:



Barbed wire:



But here's my favorite:



These products were all designed by UK company, Sweet Dreams Security.


20081016

Boxy jQuery Plug-in

I've been playing around with jQuery's AJAX capabilities lately in some PHP reports I have to do for work. I wanted to have pop-up forms to prompt the user for information and update the database without using a real pop-up window and without needing to submit the page. I found the Boxy jQuery Plug-in and found it to suit my needs nicely.

While I can't post my exact work code, I wanted to post some notes about how I did it for future reference and for others who may be just picking it up themselves.

Installation
Installation of Boxy was simple; all I had to do was copy three folders from their zipfile into my html directory.

Implementation
My page already included a jquery.js script since I was already using jQuery to do my database submits. I had to add these two lines to be able to use boxy:

<script type='text/javascript' src='javascripts/jquery.boxy.js'></script>
<link rel="stylesheet" href="stylesheets/boxy.css" type="text/css" />


I also put my "images" directory in a different place than the css expected, so I had to edit that.

For work, I had a table displaying data which was stored in the database. In one column of cells were dropdowns with the value from the database selected. I needed the user to be able to change the value and have it save to the database. I also wanted to prompt the user to enter a comment for why they were modifying the dropdown. I started with a call to a javascript function in my onchange portion of my select.

Here is my javascript code (with proprietary information modified):

function prompt_user(rowid) {
new Boxy("
<h2>Please enter a comment for the change:</h2>
<center>
<input type=\"text\" id=\"comments\"
onchange=\"update_db("+rowid+");
Boxy.get(this).hide();\"/>
</center>",
{modal:true}
);
}


I use rowid since each row in the table refers to a different row in the database and I need to be able to pass that on to the next function that will do the db update. The onchange will activate when the user either pressed enter, tab, or clicks away from the textbox. It will not activate if they just change the value of the textbox without doing one of those things (that would be an onkeypress).

The modal:true option makes the rest of the screen inactive until the user supplies the prompted information.

For my update_db function, I use jQuery to help me out. Now this isn't the best way, passing the whole db statement from here but for me it was easier to write and debug for now and it will be fixed in the final version.

function update_db (rowid) {
var comments=document.getElementById('comments').value;
$.post("submit_sql.php", {
sql_query: "update my_table set
choice='" + document.getElementById('choice_select_'+rowid).value + "',
comments='" + comments + "'
where id="+rowid},
function(error) {
if (error != '') {
Boxy.alert(error, null, {modal: true});
} else {
document.getElementById("comments_"+rowid).innerHTML=comments;
new Boxy("<h2>Success</h2>", {
afterShow: function() {
var self = this;
setTimeout(function() { self.hide(); }, 1000);
},
modal: true,
closeable: false
});
}
}
);
}


Here, I am sending the SQL query as a parameter to a separate php script. In the callback, I create a Boxy alert if there's a problem. It's a modal again, so the user cannot ignore it and has to close it before doing anything else. If there's no error, then in the callback I make sure the page updates with the comments and I alert "Success", but I have this Boxy auto-close (actually I just hide it) after 1 second (1000 milliseconds).

For reference, here is some sample html code for submit_sql.php:

<?
include('dbinfo.inc');

$conn = pg_connect( 'host=' . $dbhost
. ' dbname=' . $dbname
. ' user=' . $dbuser
. ' password=' . $dbpass )
or die ("Can't connect to db");

$queryString = $_POST['sql_query'];
$result = pg_query( $conn, $queryString );
#echo pg_affected_rows($result);
if ( !$result ) {
echo(pg_last_error());
}
?>



20081013

The Eyeballing Game

Thanks to a tweet from a friend, I tried The Eyeballing Game. It's just a silly little Flash game where you try to do geometric constructions in your head by eyeballing.

I was terrible at it, getting a 4.20 when I tried. Though I am proud of this one moment on my first try:



I did try a few more times and found that I consistently did the worst at parallelograms, as you can see my score. I then tried rushing them to see if a time limit would make things worse or if maybe going with my gut instinct was better. My scores stayed about the same, but this may not be the case for all people.


20081008

Safeguard for Drunk E-mailing

While in college, I had the habit of always checking my computer before going to bed and when waking up in the morning. Actually, pretty much anytime I came in and out of the room. Anyway, some morning I would come back to an e-mail from a friend (who I know reads this and I hope doesn't mind!) from sometime in the early e-mail. It would be a drunken e-mail explaining all the craziness from the night before, usually with a boy involved. I loved getting the e-mails, though didn't always think I did a good job of consoling.

The problem was that I wasn't the only one receiving drunken e-mails. Members of the male persuasion also received digital messages, and many that were regretted the next morning. I was highly amused when she sent me a link to Google Lab's "Mail Goggles". With "Mail Goggles" turned on, you have to answer five math questions within 60 seconds before you can send outgoing mail. The difficulty of the questions and the dates/times that the check should be automatically turned on are configurable. Then again, this friend is known to have powers that she can do drunk that she cannot do sober. Since she's already an engineer and great a math, I doubt it'd hinder her ability to do her problems.


20081006

Monthly Personal Update



Sorry, I've been sickish lately. I guess another month has gone by. September went by really quickly for me, though now that I write this post, I can't really explain why.

It was the start of fall clique ultimate league. We had a beginning of the season party, with a very nice dinner cooked by my co-captain, and lots of drunken Rock Band and Mario Kart. My team now stands at 3-1.

One of the weekends, a bunch of college friends were in town from SF, Seattle, and Pittsburgh for a wedding and some other reasons. We all went out for Ethiopian food and played some cards. It was very nice.

September also marks my little brother's birthday. He came home to spend it with family, and I introduced him Race for the Galaxy, which I had learned in July in Las Vegas. He liked it very much. We had dinner Saturday night at home with our grandmother and aunt, and on Sunday with our parents at The Melting Pot, my favorite national chain restaurant.


20081001

Netflix "Watch Instantly" Service Coming to Macs

My two closest video rental stores (Blockbuster's and Hollywood Video) have closed down. The next closest is awfully inconvenient to get to and is not on the way to anything, making it more annoying to return videos. I speculate that the combination of Netflix, ON-DEMAND on cable, DVRs, Apple TV, and those $1 one-day video rental machines in supermarkets have made going to video rental stores obsolete. My bf and I argue over which of those factors we think is a heavier culprite, but nevertheless, the market in this industry is certainly changing.

I have mentioned a few times before that we use do use Netflix and own Macs. Well, looks like now we can use them both together! Netflix just announced that their "Watch Instantly" content will be available on Macs by the end of the year. All of the Netflix "Watch Instantly" content is available for free with any level of subscription, and there is no limit on how many movies you can watch a month or a time-frame in which you have to finish watching the movie by. They have vastly increased their selection since when I first mentioned it, and I no longer run into the issue where movies disappear from availability. You can make a separate queue to bookmark "Watch Instantly" movies if you come across one you want to watch later.

While I'm enjoying watching all the HD content on our Apple TV, I like that I will now be able to watch movies off my Macbook Air when on a business trip in a hotel room, and have a large selection of movies to watch for free.