Skip to content

Instantly share code, notes, and snippets.

View hsinhoyeh's full-sized avatar

hsinhoyeh

  • footprint-ai
View GitHub Profile
@hsinhoyeh
hsinhoyeh / sort1mb.cpp
Created November 14, 2012 04:08 — forked from preshing/sort1mb.cpp
Sort one million 8-digit numbers in 1MB RAM
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
typedef unsigned int u32;
typedef unsigned long long u64;
//-------------------------------------------------------------------------
// WorkArea
//-------------------------------------------------------------------------
diff --git a/netchan_test.go b/netchan_test.go
index 44a73cc..c915c1a 100644
--- a/netchan_test.go
+++ b/netchan_test.go
@@ -99,6 +99,8 @@ func TestRecvChanAsyncLeakGoRoutines(t *testing.T) {
ec.Publish("foo", 22)
ec.Flush()
+ time.Sleep(50 * time.Millisecond)
+
#on mac
C-a Move to the start of the line.
C-e Move to the end of the line.
C-b Move back one character.
C-f Move forward one character.
C-k Kill the text from the current cursor position to the end of the line.
C-w Kill from the cursor to the previous whitespace.
C-y Yank the most recently killed text back into the buffer at the cursor.
#!/bin/bash
#setup a threshold which we are begining to clean the old files if the usage exceeds this threahold
THRESHILD=80
# find out the current uage in the file system, especiallyfor /de/sda1
# /dev/sda1 197G 143G 45G 77% /
# then we have 77 in CURRENT
CURRENT=$(df -P | grep /dev/sda1 | awk '{ print $5}' | sed 's/%//g')
@hsinhoyeh
hsinhoyeh / arduino-httpclient
Last active August 29, 2015 14:19
this gist shows how to communicate a http server via arduino uno + rsp 8299
// NOTE: the following is just a POC. codes are not purified yet.
#include <SoftwareSerial.h>
SoftwareSerial esp8266 = SoftwareSerial(3,2); // another serial which binds pix TX:3, RX:2 for comminucating ESP8266
// NOTE: the default serial is used to send debug info back to PC.
// the wifi configuration
const char wifiName[50] = "bad1", wifiPassword[50] = "illbeback";
void setup() {
@hsinhoyeh
hsinhoyeh / gist:9e8386acef8f2a79ed92
Last active August 29, 2015 14:26
[tunning] performance tunning
===dstat
apt-get install dstat
```
dstat -h
Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics
Dstat options:
-c, --cpu enable cpu stats
dongmen:
- Din Tai Fung Restaurant
http://yui0201.pixnet.net/blog/post/148597838-%5B%E9%A3%9F%E8%A8%98%5D-%E9%BC%8E%E6%B3%B0%E8%B1%90%E8%8F%9C%E5%96%AE%E5%A4%A7%E5%85%A8%EF%BC%8C%E4%B8%8D%E6%98%AF%E5%8F%AA%E6%9C%89%E5%B0%8F%E7%B1%A0%E5%8C%85%E5%96%B2%EF%BD%9E
- Green onion pancake
http://oreoritz.pixnet.net/blog/post/109530560-%5B%E5%8F%B0%E5%8C%97%E3%80%82%E6%9D%B1%E9%96%80%E7%AB%99%5D%E6%B0%B8%E5%BA%B7%E8%A1%97%E5%A4%A9%E6%B4%A5%E8%94%A5%E6%8A%93%E9%A4%85%E3%80%82%E6%8E%92%E9%9A%8A%E4%BA%BA%E6%BD%AE
- tofu pudding
http://keeat.pixnet.net/blog/post/80293615-%E6%9D%B1%E9%96%80%E6%B1%9F%E8%A8%98%E8%B1%86%E8%8A%B1
- shaved ice with diced mango
@hsinhoyeh
hsinhoyeh / golang-restful-logcontainer
Last active April 26, 2016 07:19
golang restful logcontainer
```go
package api
import (
"fmt"
"hash/fnv"
"net/http"
"net/http/httptest"
"net/http/httputil"
@hsinhoyeh
hsinhoyeh / netpps.sh
Created August 28, 2016 04:56 — forked from joemiller/netpps.sh
shell: quick linux scripts for showing network bandwidth or packets-per-second
#!/bin/bash
if [ -z "$1" ]; then
echo
echo usage: $0 network-interface
echo
echo e.g. $0 eth0
echo
echo shows packets-per-second
@hsinhoyeh
hsinhoyeh / gist:f4cf1a9d4dd1ae94bb1b26ddaba166ca
Created October 11, 2016 07:41 — forked from aioutecism/gist:2638bb9eaf9ffc13348c
Set up a VPN Server (PPTP) on AWS and use it anywhere

Set up a VPN Server (PPTP) on AWS

  1. Create a EC2 instance using Ubuntu 14.04.
  2. In Secure Group Inbound Rules, add a SSH Rule(TCP, Port 22, 0.0.0.0/0) and a Custom TCP Rule(TCP, Port 1723, 0.0.0.0/0).
  3. Optional: Associate a Elastic IP with the instance.
  4. SSH into the instance.
  5. sudo apt-get install pptpd.
  6. sudo vim /etc/pptpd.conf. Uncomment localip 192.168.0.1 and remoteip 192.168.0.234-238,192.168.0.245.
  7. sudo vim /etc/ppp/pptpd-options. Uncomment ms-dns and ms-wins. Change the IP to Google's DNS like this: