Skip to content

Instantly share code, notes, and snippets.

@dryman
dryman / xmas.pl
Created December 5, 2012 00:21
應景畫聖誕樹~
#!/usr/bin/env perl
use 5.010;
say ' ' x (10-$_) . '*' x ($_*2+1) for 0..9;
say ' ' x 9 . '*' x 3 for 0..2;
NSImage* zh_road = [NSImage imageNamed:@"zh_road.png"];
NSLog(@"%@", [zh_road representations]);
NSBitmapImageRep *rep = [[zh_road representations] objectAtIndex:0];
NSLog(@"bytes per row: %ld, bits per pixel: %ld", [rep bytesPerRow], [rep bitsPerPixel]);
unsigned long img_height = [rep pixelsHigh];
unsigned long img_width = [rep pixelsWide];
unsigned char * const bmpData = [rep bitmapData];
unsigned int * const histogram_rgba = calloc(img_width, sizeof(int));
alias ls="ls -G"
source ~/perl5/perlbrew/etc/bashrc
export PATH="/usr/local/Cellar/siege/2.70/bin/:~/bin:/Applications/MATLAB_R2011a.app/bin:$PATH"
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
@dryman
dryman / gist:2650855
Created May 10, 2012 03:27
Power Set
(defn power-set [lst]
(if (seq lst)
(clojure.set/union
(apply hash-set (for [x (next lst)] #{(first lst) x}))
(power-set (next lst)))
#{#{}}))
(defstruct rb
(l nil) (r nil) data (red T))
(defparameter *tree* nil)
(defun rb-kid (root dirs)
"Get children of node via (rb-kid node '(nil nil T nil))
where nil means left and T means the right branch of a node."
(if (endp dirs) root
(if (car dirs)
(rb-kid (rb-r root) (cdr dirs))
alias ls="ls -G"
source ~/perl5/perlbrew/etc/bashrc
export PATH="/usr/local/Cellar/siege/2.70/bin/:~/bin:/Applications/MATLAB_R2011a.app/bin:$PATH"
function git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "("${ref#refs/heads/}") ";
}
function git_since_last_commit {
#import <Foundation/Foundation.h>
#import "DDFileReader.h"
#define MACRO_VALUE_TO_STRING_( m ) #m
#define MACRO_VALUE_TO_STRING( m ) MACRO_VALUE_TO_STRING_( m )
int main (int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
@dryman
dryman / IMKTest.m
Created November 15, 2011 03:04
Unit test for IMK
#import <SenTestingKit/SenTestingKit.h>
#import "NumberInputController.h"
@interface IMKTest : SenTestCase {
IMKServer* server;
NumberInputController* controller;
}
@end
# on server
if [ $TERM == "dumb" ] || [ $TERM == "vt102" ]; then
export TERM="xterm-color"
screen -RD
fi
# In irssi, /set term_charset big5
# Add client id_rsa.pub to your server .ssh/authorized_keys
# use ssh://yourId@yourserver from Nally to login ;)
sudo brew update
sudo brew install jruby # latest version is 1.6 (03/24/2010)
sudo gems update --system
sudo gems uninstall rawr # rawr should install via jruby
sudo jruby -S gems install rawr
# at root directory of CompassApp
sudo jruby -S rake rawr:bundle:app
# build location is package/osx/compass.app