Skip to content

Instantly share code, notes, and snippets.

@Jxck
Jxck / cleanup.hs
Created June 11, 2012 15:04
cleanup without .hs files
import System.Directory
import Data.List
findDotIndex :: String -> Int
findDotIndex a = case findIndex (=='.') a of
Just x -> x
otherwise -> 0
splitAtDot :: String -> (String, String)
splitAtDot x = splitAt (findDotIndex x) x
@Jxck
Jxck / binparser.js
Created August 14, 2012 07:40
binary parse for spdy
var log = console.log.bind(console);
function choiceReadLength(length) {
if (length <= 8) return 8;
if (length <= 16) return 16;
if (length <= 32) return 32;
throw new Error('too large length');
}
function choiceReadMethod(readLength) {
@Jxck
Jxck / next.js
Created October 17, 2012 16:01
非同期と next()
log = console.log.bind(console);
var assert = require('assert');
function test() {
var tests = Array.prototype.slice.call(arguments);
function next() {
if(!tests.length) return;
var args = Array.prototype.slice.call(arguments);
args.push(next);
var t = tests.shift();
var mongoose = require('mongoose');
mongoose.connect('localhost', 'testing_invalidate');
var schema = new mongoose.Schema({
name: { type: String, required: true },
pass: { type: String, required: true },
});
schema.methods.setPassword = function setPassword (pwd, confirm) {
if (pwd === confirm) {
Verifying that +jxck is my blockchain ID. https://onename.com/jxck
func padding(str string) string {
return strings.Repeat("0", 8 - len(str)) + str
}
@Jxck
Jxck / .gitignore
Created January 24, 2013 16:32
Socket.IO sample for Node.js_jp ML
node_modules
@Jxck
Jxck / .gitignore
Last active December 18, 2015 19:09
blog sample advanced go concurrency pattern
.DS_Store
@Jxck
Jxck / testcase.1.txt
Last active December 22, 2015 12:49
HPAC の Encoding 戦略の考察
全て Without Indexing で送るパターン
HT を更新しない。
結果的には :scheme, :method くらいしか使いまわさないパターン。
[1]
HeaderSet
:scheme: https
:host: jxck.io