Skip to content

Instantly share code, notes, and snippets.

@changtimwu
changtimwu / allowall.sh
Created April 29, 2013 01:29
open all traffic
#!/bin/sh
echo "Stopping firewall and allowing everyone..."
iptables -F
iptables -X
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
@changtimwu
changtimwu / snmppass.coffee
Created June 18, 2013 05:22
netsnmp agent pass_persist to unix socket example
net = require('net')
mib_entries=[]
@add_entry = (oid, type, cb)->
mib_entries.push
oid: oid
type: type
cb: cb
@changtimwu
changtimwu / oid_sort
Last active December 18, 2015 16:39
oid sort example
prvs_tmp = []
prvs_tmp.push { oid: ".1.3.6.1.6.3.15.1.1.#{i}.0", handler:{}} for i in [1..6]
prvs_tmp.push {oid:'.1.3.6.1.2.1.4.1.0' , handler:{}}
prvs_tmp.push {oid:'.1.3.6.1.23.13.4.1.0' , handler:{}}
prvs_tmp.push {oid:'.1.3.6.1.2.12.4.1.0' , handler:{}}
prvs_tmp.push {oid:'.1.3.6.1.23.12.4.1.0' , handler:{}}
prvs_tmp.push {oid:'.1.3.6.1.2.1.31.1.1.1.6.12' , handler:{}}
prvs_tmp.push {oid:'.1.3.6.1.2.1.31.1.1.1.6.11' , handler:{}}
mibentries = prvs_tmp
fs = require("fs")
writereg = (offt,rval)->
to8dhex = (val)->
s=val.toString(16)
pre0=''
pre0+='0' for i in [1..(8-s.length)]
pre0+s
rdfn="/proc/resource_dump"
fs.open rdfn, 'r+', null, (err, fd)->
return if not fd?
@changtimwu
changtimwu / mymv1.csv
Created September 23, 2013 08:09
some MV songs
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
340049 F 如影隨形 江美琪 1 4 0 http://i.eimg.com.tw/d/alb/30/49730.100.jpg?ver=0 H90074
82258 F 如果 邰肇玫 1 2 0
390002 F 如果下個路口遇見你 許茹芸 1 9 0 http://i.eimg.com.tw/d/alb/41/27441.100.jpg?ver=0 I20398
35595 F 如果不想要 蔡依林 1 5 0 YS-0272
16900 F 如果你也聽說 張惠妹 1 6 0 http://i.eimg.com.tw/d/alb/65/92865.100.jpg?ver=0
360091 F 如果你也聽說 張惠妹 1 6 0 http://i.eimg.com.tw/d/alb/65/92865.100.jpg?ver=0 B71136
82729 F 如果你愛我 蔡健雅 1 5 0 http://i.eimg.com.tw/d/alb/44/98444.100.jpg?ver=0
350211 F 如果你愛我 蔡健雅 1 5 0 http://i.eimg.com.tw/d/alb/44/98444.100.jpg?ver=0 B71280
36037 F 如果你是李白 莫文蔚 1 6 0 http://i.eimg.com.tw/d/alb/36/45336.100.jpg?ver=0 G80078
300010 F 如果在你懷裡滿足的死掉 徐懷鈺 1 11 0 http://i.eimg.com.tw/d/alb/5/88605.100.jpg?ver=0 B71099
http = require("http")
url = require("url")
path = require("path")
fs = require("fs")
dirname = '.'
servfunc = (request, response) ->
uri = url.parse(request.url).pathname
filename = path.join( dirname, uri)
fs.exists filename, (exists) ->
@changtimwu
changtimwu / mcast_iface.coffee
Last active August 29, 2015 13:58
specify interface to send out multicast packets
os =require 'os'
dgram = require 'dgram'
test_send = (ifaddr)->
MDNS_PORT = 5354 # OSX refuses app to use port 5353
MDNS_ADDRESS = "224.0.0.251"
s = dgram.createSocket('udp4')
ver = Number(process.versions.node.split('.')[1])
if ver==10
s.bind MDNS_PORT, ifaddr, ->
@changtimwu
changtimwu / gostudy.md
Last active August 29, 2015 14:00
go study notes

var:= 的差異

  • := 一定要給初值
b:=3
baz:= []int {3,4,5}
baz:= [3]int   // error! 缺乏初值
  • var 可以給初值也可以不給
@changtimwu
changtimwu / newspress.md
Last active August 29, 2015 14:01
newspress

Intrising technologies is a custom electronics design services company focusing on communication devices for mission critical scenarios. The main application includes L2/L3 ethernet switches used in mobile backhaul, factory automation, smart rail and power planets. With years of strong experience in protocol implementation and firmware engineering, Intrising provides the electronic design consulting services as well as full turnkey product from development to mass production.

In 2012, Intrising announced the world’s first industrial Ethernet switch supporting ITU.G8032. With the sub 50ms convergence time, they offer customer can get ultra-fast failure recovery without sacrificing interoperability.

A2e Technologies is a Custom Electronics Design Services (EDS) firm.
As one of the top Product Design Companies in the industry, we provide embedded systems and electronic product design consulting services as well as full turnkey product development through our multiple design centers. We provide everythi
@changtimwu
changtimwu / mutstudy.md
Created July 26, 2014 02:20
git mutable type study

struct 真的是copy value , 要用 pointer 才能指到同一個 struct variable

package main

import "fmt"

type myst struct {
	age int
}