Google
 

Wednesday, September 17, 2014

And the Vending Machine Gods Smile Upon Me

My team lead wanted to buy a $0.75 Coke from the vending machine downstairs, but he only had $0.50. He asked around for a quarter, but nobody had any, so I gave him $1.00. He gave me his $0.50 and promised to give me the $0.25 change when he got back.

When he returned, he was carrying both a Coke and a Dr Pepper (the nectar of the gods), which he gave me in addition to the quarter. Apparently, when he punched in his request for a Coke, the machine gave him both.

Sometimes, Karma works in your favor. Mmm... Dr Pepper.

Friday, April 4, 2014

Automated SVN Deployment

After much gnashing of teeth, I've finally managed to build a bash script to automate deployment of my builds to production/staging for my in-progress website.

Note that the SVN hooks directory, as well as the working directories for the SVN must all be owned by the user that the hook script is executing as. In my case, the user was www-data, so I needed to run chown -R www-data /var/svn/repo/hooks, chown -R www-data /var/www/production, and chown -R www-data /var/www/staging. This also needs to be a post-commit script in order to function properly. Staging and production must also be manually set up as working directories. Staging should be on /trunk, but it doesn't particularly matter what production is set to, as it will soon change.

Now, my script isn't the most secure in the world, this I know. Mainly, because I've got the SVN username and password stored in plaintext in the script. At this point, though, I don't care. Here's the script!

#!/bin/sh
USER='username'
PASS='password'
REPOS="$1"
TXN="$2"

/usr/bin/svn update /var/www/staging --non-interactive --trust-server-cert --username-"$USER" --password="$PASS"

SVNLOOK=$(/usr/bin/svnlook history -r "$TXN" "$REPOS" /tags | grep "$TXN")

if [ -n "$SVNLOOK" ]; then
TAG=$(/usr/bin/svn ls "file://$REPOS@$TXN" "^/tags" | tail -1)
/usr/bin/svn switch "file://$REPOS/tags/$TAG" /var/www/production --username="$USER" --password="$PASS"
fi

What It Does:

$1 and $2 are the parameters automatically passed to the post-commit; the name of the repository and the revision number just committed, respectively. First, the staging site is updated to the most recent revision of the trunk (--non-interactive --trust-server-cert is used because my certificates have bad validation :P). Then, the script looks at the SVN history for the current revision, checking whether there's anything in the /tags directory. If there is a change to anything in /tags for this revision, we obtain the most recent folder, and switch to it on production.

The Result:

When you commit a change to the repository, the staging site is updated. When you tag a revision, the production site is updated. Thus, staging will always have the most recent (though possibly broken) build of the application, and production will always have production builds.

Tuesday, July 24, 2012

My Little Exalt

I have recently become a brony, watching My Little Pony: Friendship is Magic. The show's actually quite good.

After becoming a brony, I began to read MLP fanfiction on fimfiction.net. Then a friend of mine talked to me about his ideas for writing his own fanfic, and that spurred me on to write a fic of my own.

All of that boils down to the creation of My Little Exalt, a crossover fanfic between My Little Pony and Exalted. The ponies are in Creation. The Dowager is in Equestria. Pinkie Pie is a Sidereal exalt, Chosen of Serenity (y'know, the party exalted). Let the hijinks ensue.


So far I've published the prologue and two chapters, with many more planned in my crazy-dome. Wish me luck!