Skip to content

Instantly share code, notes, and snippets.

View homerquan's full-sized avatar

Homer Quan homerquan

View GitHub Profile
sealed trait Obj
case class Error(error:String) extends Obj
case class DataA(a1:String, a2: Int) extends Obj
case class DataB(b1:String, b2: Boolean) extends Obj
val strA = """{"a1":"foo", "a2": 1}"""
val strB = """{"b1":"bar", "b2": false}"""
val srtE = """{"error": "oops"}"""
object JsonProtocols extends DefaultJsonProtocol {
intexit() {
# Kill all subprocesses (all processes in the current process group)
kill -HUP -$$
}
hupexit() {
# HUP'd (probably by intexit)
echo
echo "Interrupted"
exit
@homerquan
homerquan / gist:bd5506745afd98d0422b399ab8f33e70
Created April 8, 2017 22:59
setting for tensorflow with cuda on mac (with cudnn)
export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH=${CUDA_HOME}/lib:${CUDA_HOME}/extras/CUPTI/lib:/Developer/NVIDIA/CUDA-8.0/lib
export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
export PATH=$DYLD_LIBRARY_PATH:$PATH
lsof -n -i4TCP:$PORT | grep LISTEN
Math.random().toString(36).substring(7);
// part A
var client = require('seneca')()
.use('seneca-amqp-transport')
.client({
type: 'amqp',
url: 'amqp://guest:guest@localhost:5672/seneca',
pin: 'role:test2'
})
.client({

Add Sublime Text to OS X Context Menu

  • Open Automator
  • Create a new Service
  • Add a Run Shell Script action
  • Set input to Service receives selected files or folders in any application
  • Set the script action to /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl -n "$@"
  • Set Pass input to as arguments
  • Save as Open in Sublime Text
var client = io.connect(socketURL, options);
client.on('connect', function(data) {
console.log("client receive connect" + data);
});
client.on('connect_confirm', function(data) {
console.log('confirm');
});
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "puppetlabs/centos-7.0-64-puppet"
config.vm.host_name = "socket"
config.vm.network "forwarded_port", guest: 8004, host: 8004
config.ssh.forward_agent = true
# AKKA Actor snippets
## [scala][akka] avoid sender mixing (using pattern match guard)
```
def receive = {
case x if sender == child1 => do sth
case x if sender == child2 => do sth else
case x => child forward x
}