Posts

Showing posts from 2011

Every Time You Write a Regular Expression You Should Be Required to Put Sample Input in a Comment

There's a reason PERL has a reputation for being unreadable: regular expressions are almost impossible to decipher without any context. Consider seeing the following in a python script: conf_regex = " *(\d+) +(\d+\.\d+\.\d+\.\d+)/(\d+) +(\d+\.\d+\.\d+\.\d+) +(\d+) +(.+) *" From the variable name you can infer it's being used to parse a conf file, but that's about it.  Now compare that to the following: # regex for parsing conf file, example entry below # #id     network             addr        port    connections # 0       155.246.80.0/24     127.0.0.1   5000    0,3 conf_regex = " *(\d+) +(\d+\.\d+\.\d+\.\d+)/(\d+) +(\d+\.\d+\.\d+\.\d+) +(\d+) +(.+) *" Suddenly it's not so bad.

aspire 4830T no sound ubuntu fix

I just bought a new Aspire TimelineX AS4830T-6642 laptop, and when I installed Ubuntu 11.04 64-bit I had no sound whatsoever. If you have the same problem here's what to do: The fix is here: http://people.canonical.com/~diwic/temp/alsa-hda-dkms-acer3830tg_0.1_all.deb Download the file and save it.  Open it and the Ubuntu Software Center should come up with an option to install.  Install it (if it says that it's untrusted, ignore this and proceed).  Once the installation is complete restart your computer and you should have sound. note1: This fix originally came from post #76 of this bug: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/783582 note2: Make sure you do this on a fresh install of Ubuntu 11.04, one where you have not already tried other fixes.  I originally applied this patch after trying to install some ALSA drivers and screwing around with some other stuff, and it got my sound working, but jack sense was broken.  After doing a fres...

Web Deployment With Git

This is my solution to do the following 1) deploy a website from my local machine to my server in one step 2) keep a git repository on the server (mainly to have it as backup) I use a combination of git push and rsync to achieve this. Create git repositories on your local machine and the server. 1) create a bare git repository on the server (this is the repository that will be pushed to) $ mkdir /home/cogan/git_projects/myproject.git $ cd myproject $ git init --bare 2) create a git repository on the development machine (where you will do the deployment from) $ mkdir /home/cogan/projects/myproject $ cd myproject $ git init add a test file to the git repository and commit $ echo "<h1>[G]It Works!</h1>" > test.html $ git add test.html $ git commit -m "initial commit" Set up remote repository 3) On your local machine add the repository on the server as a remote repository called 'web' $ git remote add web ss...

Terminate Scripted Minicom Session

If you start a minicom session with the -S you can automate a minicom session with runscript.  This starts two separate processes, the minicom process and the runscript process.  If you want to close the minicom session when the script is finished, simply calling exit in the runscript isn't enough. To End the minicom session you have to kill the minicom process, using the ! operator within the script to execute an external command. The easiest method is to run ! killall minicom This isn't recommended if you might have multiple minicom processes running.  A better way is to use pkill to target the correct minicom session ! pkill -f "^minicom conf_file -S script_file$" Where conf_file and script_file are the names of your minicom files.  pkill uses a regex to kill the process that you specify. Of course to use pkill you have to be able to generate the script file dynamically, or make sure you always call minicom with the same command when you use it....

What Twitter Tells Us

I was in the computer lab at work the other day and my coworker was watching a gamecast of a NY Yankees preseason game online.  Now let me tell you, this guy is a Yankees fanatic.  He's the kind of guy who has every player's batting average memorized to three decimal places.  Just to give you an idea, he brought in cake for the entire lab just to celebrate the first day of Spring Training. Anyway, one of the other guys joked that throughout the season we should remotely hijack his computer at critical moments during the games and kill his browser or play other dastardly pranks.  We quickly started talking about automating this process (we are software engineers, after all), and I had the idea that we should monitor twitter for tweets about the Yankeers and perform a shutdown whenever the buzz reached a certain threshold.  It seemed like it might actually work, and it got me thinking about twitter and what sort of secrets it may hold. I read an article a litt...

Large Numbers

Today I was reading the wikipedia page on names of large numbers and I came to a stunning realization: there are some pretty dumb names for numbers out there.  What the hell is a Septendecillion?  That sounds more like a pokemon than a number.  And to my greatest amazement, there's no recorded numerical value for a "bajillion," which is probably one of the most popular numbers of all time.  So in light of this, I move that bajllion be given a numerical value.  And why not?  It is a fan favorite after all.

Starcraft 2 Galaxy Map Editor - Speeding up Development in the Data Editor

When creating new units, abilities, attacks, etc.  most of the tutorials I've seen recommend to create a duplicate of whatever you want to change.  As anyone who has done this knows, it takes forever.  If you want to create, for example, a powerful marine that deals more damage you have to duplicate the unit, the actor, and the attack, and make sure everything is linked up properly.  This... is... tedious... But if you know that you want all marines to deal 100 damage on your map, why go through the trouble of preserving the old marine at all?  Wouldn't it be better to just quickly edit its damage?  To do this just edit the Marine - Gauss Rifle (Damage) directly.  The Data Editor will automatically create a duplicate of that effect with your map as the source.  This will override the standard Libery.SC2Mod Attack and modify the damage as intended.  If you ever want to get the old Marine damage back it's still there, so there's nothing to fe...

Starcraft 2 Galaxy Map Editor - Create an Attacking Building

Image
This tutorial shows how to create an attacking building in the Starcraft 2 Galaxy Editor.  In this example we will create a Deadly Supply Depot: a Supply Depot with a Photon Cannon attack.  This requires editing 2-3 different data types for the Supply Depot: the Unit, the Actor,and possibly the Weapon. To get started create a new custom map and fire up the Data Editor. Unit 1) Select Data Type: Units and find the Supply Depot unit.  You might see several Supply Depot Units with different Sources.  Pick any one, they are the same. 2) Right click the Supply Depot and click Duplicate Unit... Leave Supply Depot checked and don't check anything else.  This will tell our Deadly Supply Depot  to share all of these "things" with the existing supply depot.  We'll end up duplicating a few things ourselves later, but leaving the boxes unchecked prevents the creation of a lot of unneeded junk.  Click OK. 3) A Supply Depot Copy unit has...

Starcraft 2 Galaxy Map Editor - Change the Size of a Building

Image
This tutorial shows how to change the size of a building in the Starcraft 2 Galaxy Editor.  In this example we will modify a Supply Depot to be of size 1x1.  This requires editing 3 different data types for the Supply Depot: the Unit, the Actor, and the Model(s). To get started create a new map and set the type to custom.  Go to View->Show Grid and check the small option.  Now we'll be able to verify that our new Supply Depot is indeed 1x1.  Once that's taken care of hit F7 or go to Modules->Data Editor to fire up the Data Editor. Unit In this section we're going to create a new Supply Depot called Tiny Supply Depot. 1) Select Data Type: Units and find the Supply Depot unit.  You might see several Supply Depot Units with different Sources.  Pick any one, they are the same. 2) Right click the Supply Depot and click Duplicate Unit... Leave Supply Depot checked and don't check anything else.  This will tell our Tiny Supply Dep...