Skip to content

Instantly share code, notes, and snippets.

@changtimwu
changtimwu / prompt_test.coffee
Created May 24, 2012 01:02
demostrate how to delay prompt after job completion
readline = require('readline')
rl = readline.createInterface(process.stdin, process.stdout)
prefix = 'OHAI> '
rl.on 'line', (line)->
switch line.trim()
when 'hello'
setTimeout (->
console.log 'world!'
rl.prompt()
@changtimwu
changtimwu / cpssenvs.sh
Created June 12, 2012 02:18
env variables created during CPSS build
export OS_HOST=Linux
export MKDIR=mkdir
export COPY=cp
export RM=rm
export MAKE=gmake
export MD=makedepend
export TOUCH=touch
export CPU_TOOL=arm
export DRAGONITE_TYPE=A1
export CPU_FAMILY=CPU_ARM
@changtimwu
changtimwu / envdiff.sh
Created June 12, 2012 02:21
to capture all var exported during CPSS build
envdiff()
{
nm=$1
if [ ! -f /tmp/pre_$nm.env ]; then
env > /tmp/pre_$nm.env
else
env > /tmp/post_$nm.env
diff -ur /tmp/pre_$nm.env /tmp/post_$nm.env >> /tmp/allenv.diff
fi
}
@changtimwu
changtimwu / envsend.py
Created June 26, 2012 08:29
python script to send bunch of uboot envs to uart
import os,sys
import time
f=open( sys.argv[1])
for line in f:
line = line.strip(' \r\n')
args=line.split('=')
key = args[0]
val= '='.join(args[1:])
if len(args)>1:
sline = "setenv {0} '{1}'".format( key, val)
@changtimwu
changtimwu / swot.md
Created August 30, 2012 07:03
swot for proposal

|Strengths | Weaknesses | Opportunities | Threats |

|Reputation in marketplace | Shortage of consultants at operating level | x | x |

| x | x | x | x |

@changtimwu
changtimwu / ping_modeling.md
Created September 22, 2012 05:33
modeling ping as a measurement for link-change takeover

RTT and ping interval

   +--RTT -+------------------------- ping interval -----------------------+-----+
  ping   pong                                                               ping pong   

recovery time:

 +---------------------+
@changtimwu
changtimwu / config.yml
Created September 24, 2012 10:02
bug of yamlparser
#External configurations from user
system :
sys :
name : "IES-2307C"
description : "V3.13 2012-03-01"
location : "Taiwan Taipei"
contact : "default"
timezone_offset : 0
lldp :
# 只會被執行一次, 而不是每次new 都執行
myvar_init = ->
console.log 'got myvar_init'
3
# class 不是典型的declare , class內所有的member 都佔有實體, class member 真正在做的是設定初始值, 而非type
class Packet
debugFlags : false
stpMac: new Buffer [ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x00 ]
@changtimwu
changtimwu / singleton_parameter.coffee
Created October 8, 2012 02:22
to demonstrate a typical singleton in coffeescript
class Parameter
_instance=null
someparam: 'bingo'
constructor: ()->
console.log 'Parameter got constructed'
showparam: ->
console.log 'someparam is ', @someparam
setparam: (s)->
@someparam = s
@get: ->
@changtimwu
changtimwu / csscope.coffee
Created October 11, 2012 00:55
coffeescript class variable scope
class myclass
local_var=[]
local_func = ->
local_var+=1
local_func_wrong = ->
@myclass.class_var++ # wrong! no way to access class var
@inst_var++ # wrong! no way to access instance var