Code for Concinnity

tmux-sync — Open a dozen of synchronized tmux panes easily

While managing server clusters I often want to open SSH session to a dozen of machines and have them run the same set of commands, interactively. So I wrote tmux-sync to do this:

tmux-sync my-session 'ssh host1' 'ssh host2' 'ssh host3' 'ssh host4'


The above command drops you into a tmux session like below. Your input will be sent to all the panes in tmux:

The source code:

A Clean Approach to Partial Object Validation with Rails + Wicked Wizard

This is cleaner than the official method IMO, because it involves zero / minimal model object modification. The wizard logic clearly belongs to the controller only.

The basic ideas are:

• Derive from the ActiveRecord
• Override save to make Wicked behave. You can do arbitrarily complex thing there without wrangling with validation conditions.

Here’s the code:

Here is another version using a partial flag to persist the partial object in database:

Performance benchmark for Windows EFS, and BoxCryptor

Didn’t have the time to do a very serious benchmark but in case this is useful:



Some SSD, unencrypted

$dd if=/dev/zero of=zero bs=500M count=1 1+0 records in 1+0 records out 524288000 bytes (524 MB) copied, 4.42172 s, 119 MB/s Some SSD, with EFS$ dd if=/dev/zero of=zero bs=500M count=1
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 13.4115 s, 39.1 MB/s

Some SATA HDD, unencrypted

$dd if=/dev/zero of=zero bs=500M count=1 1+0 records in 1+0 records out 524288000 bytes (524 MB) copied, 8.64324 s, 60.7 MB/s Some SATA HDD, BoxCryptor$ dd if=/dev/zero of=zero bs=500M count=1
1+0 records in
1+0 records out
524288000 bytes (524 MB) copied, 17.8249 s, 29.4 MB/s

Another run using a Mac with some SSD hard disk. CoreStorage vs. TrueCrypt vs BoxCryptor:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23

Unencrypted, SSD

$dd if=/dev/zero of=zero bs=500m count=1 1+0 records in 1+0 records out 524288000 bytes transferred in 1.431038 secs (366 MB/sec) CoreStorage (AES-XTS, default), SSD$ dd if=/dev/zero of=zero bs=500m count=1
1+0 records in
1+0 records out
524288000 bytes transferred in 3.975945 secs (131 MB/sec)

TrueCrypt (AES-XTS, default), SSD

$dd if=/dev/zero of=zero bs=500m count=1 1+0 records in 1+0 records out 524288000 bytes transferred in 3.984627 secs (131 MB/sec) BoxCryptor, SSD$ dd if=/dev/zero of=zero bs=500m count=1
1+0 records in
1+0 records out
524288000 bytes transferred in 8.353867 secs (62 MB/sec)


“One-click” Rakefile to build .framework for iOS

This technique is based on Jeff Verkoeyen’s method. I find that modifying .xcodeproj files to be rather inconvenient so I whipped up a Rakefile that can be easily copied and pasted into new projects:

Ultimate Mac keyboard trick

After two years of using Mac, I just discovered the wonder of the Help menu item.

⌘ + /

If you are like me and regard yourself as a “pro” user you’d probably discard Help as something you’ll never need. But the fact is that you can access every menu item from the search field:

I have always thought that Windows does a better job at serving “pro” users due to menu access shortcuts (Alt + something). This thing from Mac is arguably more hacker friendly.

Vim keybindings in Xcode

Finally @JugglerShu stepped up and wrote the wonderful XVim. I just have the spread the word and personally report that it worked right out of the box. Thanks JugglerShu!

Install Passenger nginx on OS X with Homebrew

A clean and hack-less way to do it.

If you got the Undefined symbols for architecture x86_64: "_pcre_free_study", this is for you:

# Let Homebrew install the required dependencies
$brew install nginx # Remove it because we're using Passenger's ngnix$ brew uninstall nginx

$sudo mkdir -p /opt/nginx$ sudo chown -R $(whoami):admin /opt/nginx$ LIBRARY_PATH=/usr/local/lib CC=gcc passenger-install-nginx-module

# Done!

But… why not Flash?

If you showed Meteor’s screencast to a semi-techy friend, you might get asked that question. Sure, Meteor makes your Web app look cool and slick with all the real-time updates and stuff.

But actually, deep down you know that Flash could already do that ten years ago. I mean, even Java Applets could do “real time” dead reckoning a decade ago. You may argue that we couldn’t have done it in a Web browser 10 years ago — but in terms of actual functions performed, it’s difficult to get any solid arguments.

But Flash requires a plug-in!

Typical arguments against Flash:

• It requires a plug-in — before Steve Jobs banned Flash for political reasons, its penetration rate was 95%+
• It’s proprietary — as is Windows, Photoshop, and even iOS.
• It impedes SEO — as if a dynamic Web application is very SEO friendly.

Lesson Learned?

So what can we make of it? Flash more or less killed itself when acquired by Adobe which led it down the path of stagnation and non-innovation.

Of course, it’s not like getting $9M in funding is a success measure in and of itself. Definitely not fair where Flash is a solid revenue generating product vs Meteor a “welfare” project. So we’ll see… Published by kizzx2, on August 13th, 2012 at 10:54 pm. Filled under: UncategorizedNo Comments Local/project-based .ackrc If you use Ack, you may be annoyed by the fact that it only reads$HOME/.ackrc but not the project-local ./.ackrc.

It turns out it is quite easy to do it yourself by creating a simple shell script wrapper and then aliasing the ack command:

#!/bin/sh
# ack.sh

ackrc=""
if [ -f ./.ackrc ]
then
ackrc=$(tr '\n' ' ' < ./.ackrc) fi ack$ackrc $* # ~/.bashrc alias ack="$HOME/bin/ack.sh"

That’s it! Now I can create a .ackrc file at project root like this:

--ignore-dir=tmp
--ignore-dir=logs
--ignore-dir=vendor


Now using this technique, one can easily create a wrapper than reads both \$HOME/.greprc and ./.greprc and you get Ack’s functionality in grep! Now you wonder if we really need Ack at all 😛

WinDBG + SOS: Failed to load data access DLL, 0x80004005

Today I received a dump file from a client. I fired up WinDBG and met this dreaded error. If you stumble upon this post you have probably tried all the other Google solutions (such as updating to the latest WinDBG).

Here are what I tried, and failed:

> .cordll -ve -u -l
CLR DLL status: No load attempts

> .exepath+ C:\path\to\mscordacwks.dll
(No use)


Here is how I solved it:

• First, I run the .cordll command that everybody recommends

> .cordll
CLR DLL status: ERROR: Unable to load DLL mscordacwks_x86_x86_2.0.50727.3625.dll, Win32 error 0n87


• The client was running Windows Server 2003 SP2. The mscordacwks.dll I have in my Windows 7 box was 2.0.50727.5448

> !sym noisy
> !clrstack

CLRDLL: c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscordacwks.dll:2.0.50727.5448 f:0
doesn't match desired version 2.0.50727.3625 f:0
CLRDLL: Unable to find mscordacwks_x86_x86_2.0.50727.3625.dll by mscorwks search
CLRDLL: Unable to find 'mscordacwks_x86_x86_2.0.50727.3625.dll' on the path


• So, it looks like this DLL is actually missing on MS’s server.

• In a desperate atttempt, I tried to search the file in Google

• To my surprise, I found the file in a security update

• I downloaded the x86 file, opened the file in a zip and scavenged the required DLLs from there.

• I had to rename the DLL files. In particular, I needed to duplicate mscordacwks.dll to mscordacwks_x86_x86_2.0.50727.3625.dll to please WinDBG

• Load SOS manually .load C:\newly\downloaded\sos.dll

• .sympath+ C:\newly\downloaded; .reload

• (You may encounter an error if you have 2 SOS loaded at the same time. .chain, .unload should take care of stuff)

• Volia! Now the game begins 🙂