Here’s what I’ve been up to lately: FreeBSD, vim, tmux, command line twitter client (ttytter) and unicode-capable graphic terminal (jfbterm). No X-Windows involved!

Jul 30 2010
Here’s what I’ve been up to lately: FreeBSD, vim, tmux, command line twitter client (ttytter) and unicode-capable graphic terminal (jfbterm). No X-Windows involved!

Comments Off
Jul 16 2010
I have a table of Prices: ProductID, Date, Price and Source. My application needs to load new prices but if the price already exists and it is from a “better” source, it should update existing record.
The orignal app loaded all data in SQL temp table and did a bulk insert to the target table, followed by a bulk update. Kinda simple and effecient even if too SQL-centric. The first version of my app used to check every ProductID+Date combination for existance using regular stateful NHibernate session, then load new prices using SQL Bulk load, and update each existing price using regular NHibernate session. Needless to say, not only it was slow but the gap between the read and the insert allowed new prices from other sources (my app is not the only source) to sneak into the table causing duplicate/ambigous records to appear. I needed a solution that would allow me to Insert-or-Update records fast, without resorting to temptables+SQL mess. (I have a habit of trying to minimize the amount of SQL code in my application but if nothing else worked, I would have to fall back to the old ways.)
Here’s the outline of my new solution:
Combined, these techniques are designed to make the whole operation less chatty and, in a way, achieve the effect of having the processing done on the SQL Server side.
Here’s what I discovered while implementing the above:
This summary turned out to be more elaborate than I expected. No details for you then. You can figure it out, I have trust in you.
Comments Off
Jul 11 2010
So a Java developer, a web developer and a UNIX admin go to a bar to get a drink. The Java developer and the web developer get into an argument over who’s job is more important. “Thousands of people see my work” claimed the trendy web developer. “My code runs the banks!” retorted the tidy Java developer. They both look to the UNIX admin, expecting him to have the final word. He puts down his drink slowly. He then smashes his glass on the table, jumps on it and rips off his pants. He takes a shit and rubs it in the Java devs face, and while the web dev makes a run he jumps him, ripping his eyes out and eating them. He then goes back to the cave where he lives.
Comments Off
Jul 10 2010
In order to make bash shortcuts like Alt+. work in virtual terminals, you need to modify the keyboard mappings to map the left Alt to work like Unix special “Meta” key.
You can either start with one of the existing mappings, like this:
sed 's/lalt/meta/g' /usr/share/syscons/keymaps/us.iso.kbd > /usr/share/syscons/keymaps/local.kbd
Or, if you’re not sure which keymap file you’re currently using you can get your current keybindings using kbdcontrol:
kbdcontrol -d | sed 's/lalt/meta/g' > /usr/share/syscons/keymaps/local.kbd
Then, assuming you want this change to be global, edit your /etc/rc.conf file and add the following line:
keymap="local"
Comments Off
Jul 08 2010
Just a random selection of keyboard shortcuts and other productivity tricks for bash.
Keyboard shortcuts: (use bind -p to see all current mappings)
Add following to .inputrc:
History tricks:
Tab-completion:
grep:
Other useful stuff:
Comments Off
Jul 05 2010
Quick update: the learning is going on really good. MINIX turned out to be a piece of crap, even as a learning tool. FreeBSD is much more solid. Unix System Administration Handbook turned out a better book than I expected it to be. Less about administration and more about fundamentals. The Unix Time-sharing System has been a godsend. An Introduction to the UNIX Shell was very helpful too. These 3 have my topmost recommendations to anyone starting with *nix.
I’m currently running FreeBSD 8.0 under Windows 7′s Virtual PC (the one that comes with XP Mode). The biggest pain was getting DHCP to work. The trick was to force full-duplex on the virtual Ethernet adapter and set DHCP client to run synchronously at the boot time. Here’s how my /etc/rc.conf looks now:
font8x8="cp437-8x8" font8x14="cp437-8x14" font8x16="cp437-8x16" allscreens_flags="MODE_32" synchronous_dhclient="YES" ifconfig_de0="DHCP media 100baseTX mediaopt full-duplex"
The top 4 lines configure support for 30-vertical-lines screen, as opposed to default 25-lines one.
The bottom 2 lines configure DHCP.
Another pain was adding second virtual harddrive and mounting it as /home — I finally did it using the “dedicated” method from FreeBSD Handbook.
Finally, in order to get VM to feel more responsive I had to add following setting to my /boot/loader.conf:
kern.hz=50
This is pretty much it, everything else was by-default. This was tons of fun!
Comments Off