Skip to content

Instantly share code, notes, and snippets.

View poying's full-sized avatar
🏠
I may be slow to respond.

Po-Ying Chen poying

🏠
I may be slow to respond.
View GitHub Profile
@poying
poying / README.md
Last active December 5, 2017 03:24
play cgo
$ go run cmd/main.go
// cmd/main.go
package main

import (
	"github.com/poying/tmp/foo"
@poying
poying / test.sh
Created November 12, 2017 04:44
Test script for Go project
#!/usr/bin/env bash
set -e
echo "mode: atomic" > coverage.txt
for d in $(go list ./... | grep -v vendor); do
go test -race -timeout=5s -coverprofile=profile.out -coverpkg=./... -covermode=atomic $d
if [ -f profile.out ]; then
cat profile.out | grep -v '^mode' >> coverage.txt
rm profile.out
const path = require('path');
const memwatch = require('memwatch-next');
const heapdump = require('heapdump');
const logger = require('./logger');
const settings = require('./config/settings');
memwatch.on('leak', info => {
const filepath = path.resolve(settings.HEAP_SNAPSHOT_DIR, Date.now() + '.heapsnapshot');
logger.fatal({ leak: info }, 'Memory leak');
heapdump.writeSnapshot(filepath, err => {

YQL 查詢歷史資料

select * from yahoo.finance.historicaldata where symbol = "2498.TW" and startDate = "2016-01-01" and endDate = "2016-05-01"
@poying
poying / port.md
Last active June 25, 2016 13:44
Elm 0.17 port 筆記

ADT

port 不能使用 ADT,所以任何有巢狀結構的的資料在 port 都會遇到問題。目前的解法是在 outcome 的地方先用 JSON.stringify 轉成 String,income 再用 JSON.parse 轉成 Maybe a(噴 error 的時候就是 Nothing,這個解法有點問題,暫時先這樣 :p)

Electron、Elm 搭配使用

Electron 的 Browser 端

const callbacks = {};
let callbackId = 0;

glbale.electron = window.electron = function (event, args, cb) {
  // 產生 id 是為了讓之後 done 事件被觸發時能夠找到對應的 callback function
@poying
poying / stuns
Created January 24, 2016 16:10 — forked from yetithefoot/stuns
STUN+TURN servers list
{url:'stun:stun01.sipphone.com'},
{url:'stun:stun.ekiga.net'},
{url:'stun:stun.fwdnet.net'},
{url:'stun:stun.ideasip.com'},
{url:'stun:stun.iptel.org'},
{url:'stun:stun.rixtelecom.se'},
{url:'stun:stun.schlund.de'},
{url:'stun:stun.l.google.com:19302'},
{url:'stun:stun1.l.google.com:19302'},
{url:'stun:stun2.l.google.com:19302'},
#!/usr/bin/env bash
# Requirements:
# Node.js, curl, sed, grep
# Usage:
# ./putlocker.sh <video_url> <quality> <filename>
showjs="/tmp/show.js"
if [ ! -f "$showjs" ]; then
let _try_catch = macro {
rule { catch ($e:ident) { $body ...} } => {
{
let $e = __e;
$body ...
return;
}
}
rule { catch ($e:ident if $c:expr) { $body ...} } => {
{