Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
I may be slow to respond.

Po-Ying Chen poying

🏠
I may be slow to respond.
View GitHub Profile
View README.md
$ go run cmd/main.go
// cmd/main.go
package main

import (
	"github.com/poying/tmp/foo"
@poying
poying / test.sh
Created Nov 12, 2017
Test script for Go project
View test.sh
#!/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
View leak-detect.js
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 => {
View finance.md

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 Jun 25, 2016
Elm 0.17 port 筆記
View port.md

ADT

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

View electron-elm.md

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 Jan 24, 2016 — forked from yetithefoot/stuns
STUN+TURN servers list
View stuns
{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'},
View putlocker.sh
#!/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
View multiple-catch-block.js
let _try_catch = macro {
rule { catch ($e:ident) { $body ...} } => {
{
let $e = __e;
$body ...
return;
}
}
rule { catch ($e:ident if $c:expr) { $body ...} } => {
{
You can’t perform that action at this time.