Skip to content

Instantly share code, notes, and snippets.

View nouse's full-sized avatar

Mike Wu nouse

View GitHub Profile
@nouse
nouse / xmobarrc
Last active December 18, 2015 16:19
xmonad.hs
Config { font = "xft:Noto Sans CJK SC:size=10:antialias=true"
, bgColor = "black"
, fgColor = "green"
, position = TopSize L 94 13
, lowerOnStart = True
, commands = [ Run Network "eth0" [] 50
, Run Cpu ["-L","3","-H","50","--normal","green","--high","red"] 50
, Run Memory ["-t","Mem: <usedratio>%"] 50
, Run Com "uname" ["-s","-r"] "" 36000
, Run Date "%a %b %_d %Y %H:%M" "date" 50
@nouse
nouse / yaml_class.rb
Created December 26, 2011 15:25
yaml tag
# results differently in ruby 1.8 and 1.9
require 'yaml'
class A; end
module B
class A
yaml_as "tag:ruby.yaml.org,2002:object:A"
end
end
@nouse
nouse / prime.hs
Created June 22, 2011 16:40
generate prime list with sieve and unfoldr
import System.Environment
import Data.List
prime :: [Int]
prime = unfoldr (\(x:xs) -> Just (x, sieve x xs)) [2..]
prime' :: Int -> [Int]
prime' limit = unfoldr con [2..limit] where
con [] = Nothing
con (x:xs) = Just (x, sieve x xs)
@nouse
nouse / fun.rb
Created June 2, 2011 16:04
put method before object
module Kernel
def method_missing(name, *args, &block)
if args[0].respond_to?(name)
args[0].send(name, *args[1..-1], &block)
else
super
end
end
end
@nouse
nouse / modular.coffee
Created March 21, 2011 05:43
modular js loaded in browser
this.Module = (($) ->
value = 0
pub =
init: ->
value = 10
console.log("inited #{value}")
add: ->
value += 10
console.log("value changed to #{value}")
)(jQuery)
@nouse
nouse / zombie-test.coffee
Created March 21, 2011 05:42
vows of zombie
zombie = require("zombie")
assert = require("assert")
vows = require('vows')
vows.describe('vows of zombie').addBatch(
'when visit home page' :
topic : -> zombie.visit("http://localhost:3000", @callback)
'title should be correct' : (err, browser, status) ->
assert.equal(browser.text("title"), "Correct Title")
@nouse
nouse / fib.rb
Created January 11, 2011 10:31
ruby 1.9 Fibonacci with enumerator
generic_fib = -> a, b, &c { Enumerator.new{ |y| loop { y << a; a, b = b, c[a,b] }}}
fib = generic_fib[1,1, &:+]
negative_fib = generic_fib[1,-1, &:-]
p fib.take(10)
p negative_fib.take(10)