Skip to content

Instantly share code, notes, and snippets.

View derekchiang's full-sized avatar

Derek Chiang derekchiang

View GitHub Profile
@derekchiang
derekchiang / app.html
Last active March 13, 2024 19:16 — forked from bellbind/app.html
[electron]Use electron as a Web Server
<!doctype html>
<html><head><script src="app.js"></script></head><body></body></html>
package main
import "fmt"
// WithPrefix
type prefixOption struct{}
func WithPrefix() interface {
GetOption
let HDWalletProvider = require('truffle-hdwallet-provider')
let { mnemonic, infuraKey } = require('./credentials.json')
module.exports = {
// See <http://truffleframework.com/docs/advanced/configuration>
// to customize your Truffle configuration!
//
networks: {
development: {
host: "localhost",
@derekchiang
derekchiang / Quotes.md
Last active September 4, 2017 15:41
A collection of interesting and/or inspiring quotes.

"I would have written a shorter letter, but I did not have the time." -- Blaise Pascal


"Logging into Google+ feels like logging into a seminar, or stumbling into the wrong conference room at an airport Marriott. It looks like a cubicle farm and smells like a hospital. Posting anything on Google+ is like talking into a pillow." -- BuzzFeed


#!/usr/bin/env bash
apt-get -y install postgresql-9.4 postgresql-contrib-9.4 postgresql-server-dev-9.4
###########################################
# Hack alert:
# For Postgresql 9.4, pg_rewind is not in the main source tree and
# no packages exist in the repos, so it must be compiled manually
# and installed on the image until we can move to 9.5
# See README at
goroutine profile: total 557
75 @ 0x42c78a 0x43b964 0x43a5cc 0x7dbe7f 0x458e71
# 0x7dbe7e github.com/pachyderm/pachyderm/src/server/vendor/google.golang.org/grpc.newClientStream.func3+0x40e /go/src/github.com/pachyderm/pachyderm/src/server/vendor/google.golang.org/grpc/stream.go:236
62 @ 0x42c78a 0x43b964 0x43a5cc 0x162cf26 0x458e71
# 0x162cf25 github.com/pachyderm/pachyderm/src/server/vendor/github.com/coreos/etcd/clientv3.(*watchGrpcStream).serveSubstream+0x525 /go/src/github.com/pachyderm/pachyderm/src/server/vendor/github.com/coreos/etcd/clientv3/watch.go:591
53 @ 0x42c78a 0x43b964 0x43a5cc 0x162c377 0x458e71
# 0x162c376 github.com/pachyderm/pachyderm/src/server/vendor/github.com/coreos/etcd/clientv3.(*watchGrpcStream).run+0x15b6 /go/src/github.com/pachyderm/pachyderm/src/server/vendor/github.com/coreos/etcd/clientv3/watch.go:421
heap profile: 6: 21725184 [83739: 44860896] @ heap/1048576
2: 20971520 [2: 20971520] @ 0x87f70f 0x1660812 0x866d83 0x7d3649 0x7d4c3d 0x7da5f9 0x458e71
# 0x87f70e github.com/pachyderm/pachyderm/src/server/vendor/github.com/pachyderm/pachyderm/src/client/pkg/grpcutil.WriteToStreamingBytesServer+0x8e /go/src/github.com/pachyderm/pachyderm/src/server/vendor/github.com/pachyderm/pachyderm/src/client/pkg/grpcutil/stream.go:72
# 0x1660811 github.com/pachyderm/pachyderm/src/server/pfs/server.(*localBlockAPIServer).GetObject+0x181 /go/src/github.com/pachyderm/pachyderm/src/server/pfs/server/local_block_api_server.go:99
# 0x866d82 github.com/pachyderm/pachyderm/src/server/vendor/github.com/pachyderm/pachyderm/src/client/pfs._ObjectAPI_GetObject_Handler+0x112 /go/src/github.com/pachyderm/pachyderm/src/server/vendor/github.com/pachyderm/pachyderm/src/client/pfs/pfs.pb.go:2458
# 0x7d3648 github.com/pachyderm/pachyderm/src/server/vendor/google.golang.org/grpc.(*Server).processStreamingRPC+0x7b8 /go/src/github.co
@derekchiang
derekchiang / split_owned_vec.rs
Created January 5, 2014 14:23
A Rust function for splitting an owned vector into two owned vectors.
fn split_owned_vec<T>(mut v: ~[T], index: uint) -> (~[T], ~[T]) {
assert!(index <= v.len());
let new_len = v.len() - index;
let mut new_v = vec::with_capacity(v.len() - index);
unsafe {
ptr::copy_nonoverlapping_memory(new_v.as_mut_ptr(), v.as_ptr().offset(index as int), new_len);
v.set_len(index);
new_v.set_len(new_len);
}
@derekchiang
derekchiang / json_example.rs
Created November 22, 2013 09:24
It's amazing how hard it is to get code to compile in Rust. This is the result of an hour-long struggle. It demonstrates one usage of `extra::json`. Hope it helps someone.
// Compile with rustc 0.9-pre (727b70d 2013-11-17 21:11:24 -0800)
#[feature(managed_boxes)];
extern mod extra;
use extra::json;
use std::io::stdio;
use extra::serialize::Encodable;
@derekchiang
derekchiang / simple-server.py
Created August 22, 2013 04:27
A script for serving static files from the current directory. Very handy.
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
from argparse import ArgumentParser
import socket
parser = ArgumentParser(
description='Serve static files in the current directory.')