tips

Bare-bones embedding Ruby 1.9 in C++

tung's picture

So I never have waste time trying to figure this out again, here's how to embed the current Ruby 1.9 into a basic C++ program.

1. Install Ruby 1.9

I'm running Arch Linux, so I can install the ruby1.9 package from AUR.

yaourt -S ruby1.9
Read more »

Building Redcar 0.3 under Arch Linux

tung's picture

According to its website, Redcar is "a programmer's editor for Gnome, written in Ruby and Vala. Redcar is designed to be compatible with Textmate bundles, including syntax highlighting, commands and snippets, and most keybindings are the same."

There are build instructions on GitHub, but they're skewed heavily towards the Debian-based Ubuntu distro. I use Arch, so here's what I did.

Read more »

The Git parable

tung's picture

Essential reading for any Git user:

The Git Parable

If you read my article, Git for the lazy, you at know the simple commands. The Git Parable comes from the other end: what the pieces in Git are, and why they are the way they are.

Chad Austin's 10 Pitfalls of Dirty Code

tung's picture

I recently bumped into a programming-related blog entry by Chad Austin, father of Sphere and a member of the IMVU team. Entitled 10 Pitfalls of Dirty Code, it first lists the ways code can turn sour:

  • unclear or too many responsibilities,
  • overly complicated or obscure control flow,
  • concepts that don't map to the domain,
  • too many dependencies,
  • global state,
  • or duplicated logic.

Then he goes on to list how bad code can bite you back:

Read more »

git prompt for bash

tung's picture

I found a pretty neat tip today, and here it is in action:

git prompt screenshot

It's a custom bash prompt that shows the status of the current directory if it's a git repo. Forgive the mouse, it was an innocent bystander. Yeah, I type ls a lot.

Read more »

Let's get Spelunky!

tung's picture

Spelunky is described by its creator as "La-Mulana meets Nethack": a horribly addictive mix of unforgiving yet compelling platforming action. It's been covered by many other places, so all I'm going to say is that if you've got Windows, you want to download this right now.


So instead of reviewing the game, I'm going to tell you how to kill the shopkeepers.

Read more »

Font smoothing under Wine

tung's picture

Use Linux? Use Wine? Want smoothed fonts?

Get font smoothing in Wine.

If you don't like links, here's what you do. Put this in, say, whatever.reg:

REGEDIT4
 
[HKEY_CURRENT_USER\Control Panel\Desktop]
"FontSmoothing"="2"
"FontSmoothingType"=dword:00000002
"FontSmoothingGamma"=dword:00000578
"FontSmoothingOrientation"=dword:00000001

Then as a normal user run regedit whatever.reg. Done!

Firefox 3.1+ tab switching

tung's picture

Just yesterday I switched to Firefox Minefield: the cutting edge of Firefox's development. With it came new tab switching behaviour (like Ctrl-Tab).

The new switching irks me.

Read more »

Python inline conditionals

tung's picture

I used to always use this:

x = cond and y or z

Resulting in setting x to y if cond was True, or to z if not. It does some funny things if you throw zeros into the mix, but it's usually good.

Over here is the 'proper' Python way of doing things:

x = y if cond else z

I didn't even know that existed.

Here's a trick with tuples, similar to the first:

x = (y, z)[cond]

It works because True and False in Python can be treated as 1 and 0, respectively. Watch out though, it still evaluates both y and z.

Read more »
Syndicate content