Oh frabjous day!

Made with Octopress!

Rbenv Ruby Gem Absent After Gem Install

| Comments

I thought it would be fun to install lolcommits, which automatically takes a snapshot of you and captions it with your git commit message whenever you do a commit. However, after following the simple installation steps, it appeared that lolcommits wasn’t actually installed. I tried to enable it in one of my repos, and found that the command was not in my $PATH.

Fortunately, I soon found this site. It reminded me that because I’m using rbenv, I need to run

1
rbenv rehash

after every

1
gem install

That seemed to fix it, and I am about to do my first commit (this post) to see if it works…

Edit:

Here is the image from that commit…

Onomatopoeia

| Comments

Onomatopoeia
Is my only fear.

“Woof” and “moo” and “arrrk”
Light a fatal spark.

Sparks can lead to fires.
Sparks proceed from wires.

This makes “arrrk” and “moo”
The spark that travels through.

Whoosh, the fire’s growing.
Snapple, crack, it’s glowing.

Help if you can hear.
Onomatopoeia.

Snarkly drankle arly.
It moves for its finale.

Smash! The crackle moo spark
Slowly dims to dark.

Mind destruction near.
Onomatopoeia.

Faster Vim Macros

| Comments

Today I needed to run a custom Vim macro 76 times to automatically insert the same (long) entry under a bunch of different Python dictionary keys. I started the macro recording, typed the first ‘template’, then ran it with [email protected]. However, it took a very long time. I decided to find out why it took so long.

Following instructions from stackoverflow, I ran a profile while running the macro again. It turned out that the ‘GetPythonIndent()’ function was the culprit. It took up a whole 260s. (Actually, the ‘<SNR>35_SearchParensPair()’ function inside the ‘GetPythonIndent()’ function was the real culprit.)

Of course, the best solution would be to find out why those functions were so slow, and write a patch, and submit it. However, I’m lazy, and I don’t know Vim Script, so I found another work-around.

The solution (which I think is an improvement over my former macro recording technique, even without the time problem) is to write the repeated code once, then copy it into a register. In my case I needed three registers. Then record the macro using pastes from the registers, rather than manually typing. This will prevent Vim needing to use any syntax formatting code, and the macro will run virtually instantaneously.

Installing a Compression Proxy on a Raspberry Pi

| Comments

My friend has a very low data allowance on his internet plan, and mentioned he was using a German compression proxy to compress website data upstream. I thought that it should be possible to set up my own compression proxy on a Raspberry Pi, and after a bit of research discovered ziproxy. Installation on Raspbian was simple:

sudo apt-get install ziproxy

I then opened the configuration file in /etc/ziproxy/ziproxy.conf, and tweaked a few things.

I changed the port to something slightly less obvious.

I enabled TransparentProxy (although I’m not sure that I needed to…)

I set the AuthMode and AuthPasswdFile.

Then I opened the password file, and added some usernames and passwords.

Then I restarted the ziproxy server by running

/etc/init.d/ziproxy restart

The next step was to enable port forwarding on my router from the port mentioned above to the internal IP of my Raspberry Pi. This step will be specific to your particular brand of router, so I won’t detail it here.

On the client, I was able to set up the proxy just like any other proxy. It worked! Yay!

Setting Up Emulationstation on a Raspberry Pi

| Comments

I recently installed emulationstation using petrockblog’s RetroPie-Setup script. However, I had a few issues getting emulationstation to work correctly.

I am using composite video, because I loaned my HDMI cable to friend. This meant that I had a few overscan issues. Initially, I tried changing the overscan using overscan_left, overscan_right, etc. However, I found that these settings did not affect the overscan for emulationstation. Eventually, I discovered I needed to put the line overscan_scale=1 into my /boot/config.txt file.

The next problem I had was that whenever I tried to play any NES roms, the RaspberryPi would crash, and my TV would tell me that nothing was connected. The solution, from this github issue is to open ~/.emulationstation/es_systems.cfg and find the nes section. Then find the COMMAND= section, and change /home/pi/RetroPie/supplementary/runcommand/runcommand.sh 1 to /home/pi/RetroPie/supplementary/runcommand/runcommand.sh 2

I still have an issue where emulationstation crashes when opening a second game. I’ll report back if I find a fix.

Haunted

| Comments

A Poem…

Now the nighttime softly falls,
The darkeness fills the silent halls,
The shadows flit across the walls,
And soft a phantom faintly calls,

Now the gloaming turns to night,
The stars give forth a feeble light,
The moon appears in raiments white,
And spectres shudder with delight.

Git Problems

| Comments

I was recently messing around in the git repo for this website, and suddenly, I couldn’t add a certain folder. I would run git add <folder>, but git commit and git status both said that there was nothing to commit (working directory clean). I tried removing the directory and re-adding it. Didn’t work. I tried removing it from git with git rm. It said that 'folder/' did not match any files. Finally, I did git-ls, just to see what was actually in the git index. The directory name was there, but none of the enclosed files were listed. Next, I tried git rm --cache folder/. Still didn’t work. Finally, I tried git rm --cache folder. Notice the difference between this and the previous command? All I did was remove the / from the end of the folder name. This successfully removed the entry in the git index, and I was able to add the directory again, and everything worked.

If You Can Cook You Can Program (and Vice Versa)

| Comments

Of course, it isn’t quite that simple, but the basic ideas remain the same.

  1. Find a good book (or website).
  2. Read said resource.
  3. Follow instructions in said resource.
  4. Stuff up a few times.
  5. Learn from your mistakes.
  6. Become epic.
  7. Impress your friends! Rule the world! (Maybe… =P)

Of course, what I’m really saying is that learning programming (or cooking), especially at the beginning is exactly as easy (or as hard) as following precise instructions. Similarly, becoming a master at programming (or cooking) requires practice, and the instincts learned from a thousand mistakes.

Disclaimer: I don’t personally cook very much, but I don’t think it would be that hard if I wasn’t so lazy. This raises another very important point about the parallel’s between cooking and programming. You won’t learn either if you aren’t interested. =P Disclaimer 2: I don’t presume to classify myself as an “epic” programmer. I would place myself at about number 5. on the above list. =D

Vim + Python

| Comments

I’m writing this post, not because there is a dearth of blog posts about getting Vim to play nicely with Python, but because the blog posts I followed referenced outdated versions of the python syntax highlighting scripts.

The syntax highlighting script I use is here. It has a number of improvements over the older syntax highlighting script I was using. e.g. the older script messed up all formatting after a base class definition like class NewClass:, because it expected parentheses before the colon. The new script from the above link has fixed that issue.

I also use the indentation script mentioned here. The actual script is here

For gvim / MacVim, I use the colour scheme from here. Unfortunately it doesn’t work in the non GUI Vim, so you have to use colorscheme blackboard in your ~/.gvimrc, rather than your ~/.vimrc.

comments powered by Disqus