Skip to content

Instantly share code, notes, and snippets.

View hung-phan's full-sized avatar

Hung Phan hung-phan

  • Amazon Inc
  • San Mateo, CA
View GitHub Profile

Keybase proof

I hereby claim:

  • I am hung-phan on github.
  • I am hungphan (https://keybase.io/hungphan) on keybase.
  • I have a public key ASAW4zRygWWpuDDfW0WDuwgiI3F3di_jaDRIT7RyL32mvAo

To claim this, I am signing this object:

@hung-phan
hung-phan / Twisted.py
Last active October 14, 2019 10:03
Context manager for Twisted
from functools import wraps
from ddtrace import tracer, ext
from twisted.internet import defer
from twisted.python.context import get, call, theContextTracker
_SPAN_CONTEXT = 'span_context'
_CONTEXT_OBJECT = object()
_original_deferred_init = defer.Deferred.__init__
@hung-phan
hung-phan / util.clj
Created May 2, 2015 14:37
Usefull macros for clojure
(defn collect-bodies [forms]
(for [form (partition 3 forms)]
(build-contract form)))
(defn build-contract [c]
(let [args (first c)]
(list
(into '[f] args)
(apply merge (for [con (rest c)]
(cond
@hung-phan
hung-phan / channel-mixin.js
Last active August 29, 2015 14:19
Channel mixin for js-csp and react
'use strict';
import SyntheticEvent from 'react/lib/SyntheticEvent';
import {chan, putAsync} from 'js-csp';
const ChannelMixin = {
channels: {},
getEventChannel(channelName, ...args) {
return this.channels[channelName] || (this.channels[channelName] = chan(...args));