Skip to content

Instantly share code, notes, and snippets.

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
}
@changtimwu
changtimwu / mpakcodec_study.md
Created July 26, 2014 22:56
msgpack codec study

import "github.com/vmihailenco/msgpack" 有很多限制

@changtimwu
changtimwu / rpctodo.md
Last active August 29, 2015 14:05
rpc todo jobs
  • create a smith based net/rpc codec. simulate the following two apis
    • codec.MsgpackSpecRpc.ClientCodec -- done
    • codec.MsgpackSpecRpc.ServerCodec
  • pubsub in go-smith
    • net/rpc doesn't cover this. It's required to create a server to receive calls.
  • encoding/transportation conversion
    • encoding:
      • json/msgpack gateway.
    • transportation
  • smith/sockjs gateway.
@changtimwu
changtimwu / nodejs2go.md
Created August 14, 2014 03:16
Porting CLI from NodeJS to GO
@changtimwu
changtimwu / ptpst_format.md
Last active August 29, 2015 14:06
PTP status api json structure

API ptp::get_ptp_status

[
 {
   no: 6  # Arrival Port 
   clockId: "0040c7fffe1c6fce"  # Clock ID
   corrections:  [               # Corrections
 {