Skip to content

Instantly share code, notes, and snippets.

@taka-wang
taka-wang / main.go
Last active April 16, 2023 18:34
golang mutex
// refer to http://stackoverflow.com/questions/8286806/go-programming-language-mutual-concurrent-execution
// https://gobyexample.com/mutexes
package main
import "sync"
var m sync.Mutex
var wg sync.WaitGroup
func routine1() {
@taka-wang
taka-wang / nodered
Last active March 14, 2016 03:19
node-red init script
#!/bin/sh
#
case "$1" in
start )
echo -n "Starting Node Services: "
sleep 5
cd /usr/bin/
./core > /tmp/core.log 2>&1 &
sleep 2
cd /root/node-red
@taka-wang
taka-wang / hex.go
Last active March 11, 2016 13:59
Hex bytes to string
package main
import (
"fmt"
"encoding/hex"
"strconv"
)
func main() {
a := []byte{0xFF, 0xFA} // []byte{255, 250}
@taka-wang
taka-wang / .config
Created December 14, 2015 16:02
Linkit Smart 7688 menuconfig
#
# Automatically generated file; DO NOT EDIT.
# OpenWrt Configuration
#
CONFIG_MODULES=y
CONFIG_HAVE_DOT_CONFIG=y
# CONFIG_TARGET_ppc44x is not set
# CONFIG_TARGET_realview is not set
# CONFIG_TARGET_arm64 is not set
# CONFIG_TARGET_sunxi is not set
@taka-wang
taka-wang / blink.c
Last active March 6, 2016 18:18
Arduino Serial (LED, Servo, meArm)
@taka-wang
taka-wang / install.sh
Created January 19, 2015 05:39
Install vncserver on raspberry pi
sudo apt-get install tightvncserver
sudo nano /etc/init.d/tightvncserver
sudo chmod 755 /etc/init.d/tightvncserver
sudo update-rc.d tightvncserver defaults
# run tightvncserver
@taka-wang
taka-wang / example.py
Last active April 14, 2016 14:42
install mosquitto 1.4 on raspberry pi
import paho.mqtt.client as mqtt
# The callback for when the client receives a CONNACK response from the server.
def on_connect(client, userdata, rc):
print("Connected with result code "+str(rc))
# Subscribing in on_connect() means that if we lose the connection and
# reconnect then subscriptions will be renewed.
client.subscribe("hello/world")
# The callback for when a PUBLISH message is received from the server.
// Requires NodeJS and "noble" module: https://github.com/sandeepmistry/noble
// Based on: https://github.com/sandeepmistry/noble/issues/62
var noble = require('noble');
noble.on('stateChange', function(state) {
if (state === 'poweredOn' ) {
noble.startScanning([], false);
} else {
noble.stopScanning();
}

#Install Debian on the Beaglebone Black, along with Go 1.4

##Ingredients:

  1. Internet connected computer running Mac OS X (you may substitute some other Unix/Linux box---you'll need enough disk space to hold the Debian image (about 2GB), the ability to fetch content from the Internet, uncompress xz files, and the ability to write the image to a connected MicroSD card)

  2. MicroSD card (> 4GB recommended)

@taka-wang
taka-wang / app.js
Last active August 29, 2015 14:00
naive node app
var express = require('express');
var app = express();
app.get('/', function(req, res){
console.log("get /");
res.send('hello world');
});