Suns @ Lakers – Game 3
April 29, 2006
Oh my goodness…that was probably the worst officiating I have seen this year. First off, that technical that was thrown on Boris Diaw was Kobe pushing Diaw into Parker. Player("Diaw").fouls—; Player("Kobe Bryant").fouls++;. I want to go on, but I yelled the whole game, and don't feel like complaining anymore — those refs drained me (and I'm sure they drained the Phoenix Suns as well).Yes, the suns could have played better, but that's not why I'm writing.
Vim’s Regular Expression Replacement
April 26, 2006
How great is vim’s regex replacement.
I am trying to convert this html site over to php. The html page has http://www.example.com/locations/ak.html and i need to change all 50 of those links over to http://www.example.com/locations/location.php?abbr=ak. With vim, it took less than a minute and saved my fingers from fatigue (although, this post just voided that).
Here’s how it’s done:
:%s/href="locations\/\([a-z]\{2}\)\.html"/href="locations\/location.php?abbr=\1"/gc
Use \(load-this-text-match-to-memory\) in the search and \1 in the replace to load the first value in memory.
Often I want to to match a pattern, but only replace a segment of that pattern. Here’s how: :%s/foo\zs9\ze/bar/gc will make foo9 => foobar. This may be useful when needing to replace with some incremental variable.
To learn more, :he sub-replace-special
Sausage, Peppers, and Onions
April 18, 2006
Mmmm… is all I can say about this recipe that I just found online. I am a huge fan of sausage, peppper, and onion sandwhiches. I have tried this sandwhich from many different restaurants in town, but none have compared to the ones I use to get at the Italian delis in Greenwhich, CT. After watching the Food Network's Everyday Italian program I can now make my own. The only downside to this recipe is the cost, but it makes a lot of food.
In case you were wondering, this recipe cost me $20 to make (really $40, but i didn't have any of the spices or olive oil).
Airlines
April 17, 2006
I've done a lot of flying lately and am about to book some more flights in the next two months. The following is a ranking of airlines I've flown based on their service, perks, and the amount of leg room between each seat (I'm tall!).
1. Ted (United): Headphones were free, people were nice, plenty of legroom between seats, and everything was on time.
2. Southwest: Leather seats and legroom was ok. It's been a while since I flew southwest.
3. Continental: Service is usually great. When I have family and friends come in town, I've often had them lose their luggage. I've experienced many delays. I fly continental the most, and it's easier to remember the bad experiences.
3. America West: Legroom was very poor. The seats were also very narrow. Flight was ahead of schedule, which was nice. They charged for food and headphones.
5. Delta: I use to fly this airline a lot, but not so much anymore. This is partly due to how expensive it is now, but also how miserable my experiences have been.
I understand that each airline has several models of planes, but I fly to the same destinations most of the time and receive the same model of planes.
Scroll div contents with Javascript.
April 10, 2006
I was asked to convert a flash site to html. Her flash site had images of arrows that controlled the scroll of her content, so, I was asked to reproduce that effect. Here is the code I wrote to create a custom scroll with javascript, which uses getElementById & .scrollTop. It is recommended that you initialize the scrolling div with the style of overflow: auto; thus, the user will still be able to scroll the div if they have javascript disabled.
Here's the css:
<style type="text/css">
#scroll_up {
cursor: pointer;
}
#scroll_down {
cursor: pointer;
}
#scroll_box {
height: 200px;
width: 300px;
overflow: auto;
}
</style>
The javascript
// gives up and down scroll buttons to images, spans, ... named up_name, down_name, respectively.
// will keep the default scroll_box's style overflow if it encounters errors (so make overflow: auto;)
// usage: put this after the scrollbox div: var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box');
function TextScroll(scrollname, div_name, up_name, down_name)
{
this.div_name = div_name;
this.name = scrollname;
this.scrollCursor = 0;
this.speed = 5;
this.timeoutID = 0;
this.div_obj = null;
this.up_name = up_name;
this.dn_name = down_name;
{
if (document.getElementById) {
div_obj = document.getElementById(this.div_name);
if (div_obj) {
this.div_obj = div_obj;
this.div_obj.style.overflow = 'hidden';
}
div_up_obj = document.getElementById(this.up_name);
div_dn_obj = document.getElementById(this.dn_name);
if (div_up_obj && div_dn_obj) {
div_up_obj.setAttribute("onmouseover", scrollname + ".scrollUp();")
div_up_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
div_dn_obj.setAttribute("onmouseover", scrollname + ".scrollDown();")
div_dn_obj.setAttribute("onmouseout", scrollname + ".stopScroll();")
}
}
}
this.stopScroll = function() {
clearTimeout(this.timeoutID);
}
this.scrollUp = function() {
if (this.div_obj) {
this.scrollCursor = (this.scrollCursor - this.speed) < 0 ? 0 : this.scrollCursor - this.speed;
this.div_obj.scrollTop = this.scrollCursor;
this.timeoutID = setTimeout(this.name + ".scrollUp()", 60);
}
}
this.scrollDown = function() {
if (this.div_obj) {
this.scrollCursor += this.speed;
this.div_obj.scrollTop = this.scrollCursor;
this.timeoutID = setTimeout(this.name + ".scrollDown()", 60);
}
}
this.resetScroll = function() {
if (this.div_obj) {
this.div_obj.scrollTop = 0;
this.scrollCursor = 0;
}
}
}
usage example:
<span id="scroll_up">scroll up</span> | <span id="scroll_down">scroll down</span>
<br>
<div id="scroll_box">
<p>a lot of content</p>
</div>
<script type="text/javascript">
var div_scroll1 = new TextScroll('div_scroll1', 'scroll_box', 'scroll_up', 'scroll_down');
</script>
I hope this pasted right.
Django Screen Environment
April 7, 2006
Ok, while I'm all jacked up on coffee and am in the blogging mood…
Here is how I have setup my django development environment (inspired by http://e-scribe.com/news/212):
I have a script called django_project, which creates a screen session if one does not exist; if one does exist it will then just attach to the session. django_project takes in the following args when a screen session does not exist: django_project projectname /path/to/project/home /path/to/template/home; when a screen session does exist, just django_project projectname.
here's the django_project code:
#!/bin/bash
CONFIG_FILE='/home/germ/.screenrc.django'
E_BADARGS=65
if [ ! -n "$1" ]; then
echo "Usage: `basename $0` name_of_screen [project_home_dir template_dir]"
exit $E_BADARGS
fi
name=`echo $1 | tr '[:upper:]' '[:lower:]'`
if screen -ls | egrep '^[[:space:]]+[^[:space:]]' | awk '{print $1}' | egrep ".$name$"; then
screen -x $name
else
if [ ! -n "$2" ] && [ ! -n "$3" ]; then
echo "Usage (new screen): `basename $0` name_of_screen project_home_dir template_dir"
exit $E_BADARGS
fi
export SCREEN_DP_HOME=$2
export SCREEN_DP_TEMPLATES=$3
screen -c $CONFIG_FILE -S $name
fi
And here is .screenrc.django (what sets up the environment):
# detach on hangup
autodetach on
# multiple users
multiuser on
# annoying!
vbell off
# turn off copyright notice at startup
startup_message off
# remove the following bindings
bind k #kill
bind ^k #kill
bind . #dump termcap
bind ^h #hardcopy
bind h #hardcopy
bind A #title
#change the hardstatus settings to give an window list at the bottom of the
#screen, with the time and date and with the current window highlighted
hardstatus alwayslastline
hardstatus string '%{= mw}%-Lw%{= KW}%50>%n%f* %t%{= mw}%+Lw%<'
# keep the screen around when its process terminates
# k to kill; r to resurrect
zombie kr
# load the following screens
# $DJANGO_PROJECT_HOME and $DJANGO_PROJECT_TEMPLATES are used by the script
# which will prompt you for their values
chdir $SCREEN_DP_HOME
screen -t runserver 0 python manage.py runserver
chdir $SCREEN_DP_TEMPLATES
screen -t templates 1
chdir $SCREEN_DP_HOME
screen -t models 2
screen -t views 3
screen -t urls 4
screen -t d_shell 5 python manage.py shell
screen -t mysql 6 mysql -u django -p
screen -t misc 7
Task Management – RFID Style
April 7, 2006
I learned a valuable lesson today: before you start a project that relies on some hardware, price the hardware first. I've completed all of the django code to track the amount of time spent on tasks (where each RFID Tag represents a task), but I cannot complete the project because it's going to cost over $400 in hardware. Hmm… Xbox 360 or complete the project?
So, if anyone is feeling philanthropic, I need a 13.56 MHz RFID read/write module that interfaces over RS-232 (don't feel like spending the time on USB) and the Feig 13.56 MHz pad antenna.