Skip to content

Instantly share code, notes, and snippets.

from django.utils import simplejson as json
class SerializeMethod(object):
def __init__(self):
self.type = type_
self.func = func
class CustomJSONEncoder(json.JSONEncoder):
@mecab
mecab / gist:7740345
Last active December 29, 2015 22:59
RxJS and Socket.io
var emit = Rx.Observable
.fromNodeCallback(that.socket.emit,
null,
that.socket); // Socket.io needs the socket as the context to handle ack.
emit.subscribe(function() {
// ...
});
var Rx = require('rx');
var Observable = Rx.Observable;
var match = ["ズン", "ズン", "ズン", "ズン", "ドコ"];
Observable.create((obs) => {
obs.onNext(Math.random() > 0.5 ? "ズン" : "ドコ");
obs.onCompleted();
})
.do((e) => { console.log(e); })
@mecab
mecab / color.sh
Last active December 15, 2016 02:54
hashed_color(), which outputs sets unique background for given string and eye-friendly foregrand (white or black).
#!/bin/bash
color256()
{
# Output the color code from given RGB value.
# If the sole argument given, return it directly.
# One arg usage:
# - $1: color code [0-255]
#
@mecab
mecab / wpb.sh
Last active January 16, 2017 09:41 — forked from greymd/wpb.sh
copy & paste through Web
# Usage
## Example 1 (Text)
# $ echo foobar | wpbcopy
# $ wpbpaste
# foobar
## Example 2 (Binary)
# $ cat image.jpg| wpbcopy
# $ wpbpaste | file -
@mecab
mecab / send-region-to-clipboard.el
Last active July 22, 2017 17:16
Send region to the clipboard via the xterm clipboard integration (PASTE64/OSC52)
(defun send-region-to-clipboard (START END)
;; Place https://github.com/skaji/remote-pbcopy-iterm2/blob/master/pbcopy as `cpbcopy`
(interactive "r")
(let ((infile (make-temp-file "send-region-to-clipboard")))
(write-region (buffer-substring (region-beginning) (region-end))
nil
infile
nil
'nomsg)
(with-temp-buffer
@mecab
mecab / stratum.patch
Last active November 22, 2017 09:49 — forked from bitzeny/stratum.patch
diff --git a/externals/stratum b/externals/stratum
--- a/externals/stratum
+++ b/externals/stratum
@@ -1 +1 @@
-Subproject commit 8ba1b5fd8a802b981f31dace4cf920cfb4a3907c
+Subproject commit 8ba1b5fd8a802b981f31dace4cf920cfb4a3907c-dirty
diff --git a/lib/halfnode.py b/lib/halfnode.py
index 4ffc017..aca8cc8 100644
--- a/lib/halfnode.py
+++ b/lib/halfnode.py
@mecab
mecab / stratum.patch
Created March 27, 2018 17:14
stratum-mining patch for wavi
diff --git a/externals/stratum b/externals/stratum
--- a/externals/stratum
+++ b/externals/stratum
@@ -1 +1 @@
-Subproject commit 8ba1b5fd8a802b981f31dace4cf920cfb4a3907c
+Subproject commit 8ba1b5fd8a802b981f31dace4cf920cfb4a3907c-dirty
diff --git a/lib/halfnode.py b/lib/halfnode.py
index 4ffc017..aca8cc8 100644
--- a/lib/halfnode.py
+++ b/lib/halfnode.py

Keybase proof

I hereby claim:

  • I am mecab on github.
  • I am mecab (https://keybase.io/mecab) on keybase.
  • I have a public key ASAdthX1dzIg-LfZ57mQTBw9Ej1x0jvebfuntkBt7qe6Xgo

To claim this, I am signing this object:

#!/bin/bash
set -e
# PROJECT_FROM="firebase-project-from"
# PROJECT_TO="firebase-project-to"
function getParam() {
echo $(cat .hashParameter | grep ${1}: | sed 's/.*: \(.*\),/\1/')
}