Skip to content

Instantly share code, notes, and snippets.

View homerquan's full-sized avatar

Homer Quan homerquan

View GitHub Profile
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');
});

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
// part A
var client = require('seneca')()
.use('seneca-amqp-transport')
.client({
type: 'amqp',
url: 'amqp://guest:guest@localhost:5672/seneca',
pin: 'role:test2'
})
.client({
Math.random().toString(36).substring(7);
lsof -n -i4TCP:$PORT | grep LISTEN
@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
intexit() {
# Kill all subprocesses (all processes in the current process group)
kill -HUP -$$
}
hupexit() {
# HUP'd (probably by intexit)
echo
echo "Interrupted"
exit
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 {
import akka.actor._
case class Book(title: String, authors: List[String])
class BookPublisher extends Actor {
def receive = {
case book: Book => {
println(s"Yeah! Publishing a new book: $book")
context.system.eventStream.publish(book)
# Stop an actor
## PoisonPill Messages
A PoisonPill message has special handling for all actors, including for routers. When any actor receives a PoisonPill message, that actor will be stopped. See the PoisonPill documentation for details.
```scala
import akka.actor.PoisonPill
router ! PoisonPill
```