Skip to content

Instantly share code, notes, and snippets.

@isaiah
isaiah / player
Created June 3, 2013 17:33
An audio player in golang.
package main
import (
"bytes"
"code.google.com/p/portaudio-go/portaudio"
"encoding/binary"
"fmt"
"io"
"log"
"os"
@isaiah
isaiah / url.text
Created May 22, 2018 11:19
printer driver
https://drive.google.com/open?id=1_pL0-pWX833hISo__Ho-Z3KkW-eePFsQ
@isaiah
isaiah / __class__.md
Created June 3, 2016 10:21
Question regarding __class__ closure
From b34d733deefac7fb7f96bf5408ae705c49e764fa Mon Sep 17 00:00:00 2001
From: Isaiah Peng <issaria@gmail.com>
Date: Fri, 4 Mar 2016 11:17:40 +0100
Subject: [PATCH 1/1] include jquery and materializecss for test
---
karma.conf.js | 2 ++
package.json | 2 ++
src/Select.js | 67 ++++++++++++++++++++++++++++++-----------------------------
3 files changed, 38 insertions(+), 33 deletions(-)
@isaiah
isaiah / convert.rb
Created December 28, 2015 17:43
Replace file name with metadata
require 'fileutils'
require 'taglib'
NAME = "©nam"
Dir.glob("./**/*.m4a").each do |f|
TagLib::MP4::File.open(f) do |mp4|
name = mp4.tag.item_list_map[NAME]
name = name.to_string_list.first
dir = File.dirname(f)
name = "#{dir}/#{name}.m4a"
@isaiah
isaiah / keymap.cson
Created December 27, 2015 09:08
arch migration
'atom-text-editor[data-grammar~="haskell"]':
'': 'haskell-ghc-mod:check-file'
'': 'haskell-ghc-mod:lint-file'
'ctrl-alt-t': 'haskell-ghc-mod:show-type'
'ctrl-alt-i': 'haskell-ghc-mod:show-info'
'ctrl-alt-T': 'haskell-ghc-mod:insert-type'
'': 'haskell-ghc-mod:show-info-fallback-to-type'
'ctrl-alt-I': 'haskell-ghc-mod:insert-import'
'body':
@isaiah
isaiah / gist:5539458
Created May 8, 2013 09:51
Ruby dynamic calls benchmark
n = 100000
# taken from [here](http://blog.lojic.com/2008/12/22/ruby-dynamic-method-invocation-performance/),
# but the original one use the same string all the time, which doesn't reflect real world situation
bm(12) {|x|
x.report("orig") { n.times { test = "stormy weather"; test.length } }
x.report("call") { n.times { test = "stormy weather"; m = test.method(:length); m.call } }
x.report("send") { n.times { test = "stormy weather"; test.send(:length) } }
x.report("eval") { n.times { test = "stormy weather"; eval "test.length" } }
@isaiah
isaiah / How to write JRuby native extension.md
Last active October 13, 2015 02:27
How to write jruby extension

Problem

Sometimes you found that jruby always complain about cannot find class you defined in your precious java class, that jruby failed to load the Service that defines all the classes in ruby space.

How it work

Let's talk about the way jruby load native extension, take puma as an example, Assume you have 'puma/http11.jar' in your load path, with:

@isaiah
isaiah / gist:240846
Created November 23, 2009 02:17
ankoder full attributes jobs
require "rubygems"
require "hmac-sha1"
require "base64"
ankoder_access_key = ANKODER_ACCESS_KEY
private_key = ANKODER_PRIVATE_KEY
ankoder_date = Time.now.strftime("%a, %d %b %Y %X GMT")
ankoder_action = "POST"
ankoder_path = "/download"
string = "-#{ankoder_date}-#{ankoder_action}-#{ankoder_path}-"
require "rubygems"
require "hmac-sha1"
require "base64"
ankoder_access_key = ANKODER_ACCESS_KEY
private_key = ANKODER_PRIVATE_KEY
ankoder_date = Time.now.strftime("%a, %d %b %Y %X GMT")
ankoder_action = "GET"
ankoder_path = "/video.xml"
string = "-#{ankoder_date}-#{ankoder_action}-#{ankoder_path}-"