Skip to content

Instantly share code, notes, and snippets.

View nashibao's full-sized avatar

Naoki Shibayama nashibao

View GitHub Profile
process = require('process')
_start = Date.now()
_title = ""
_mem = 0
tic = (title) ->
_title = title
_start = Date.now()
console.log(_title, '..');
_mem = process.memoryUsage().heapUsed
@nashibao
nashibao / cf_filter.coffee
Created April 16, 2017 01:31
crossfilter filter function
dim.filter([100, 200]) # range
dim.filter(120) # equal
dim.filter((d) -> return d % 2) # function
@nashibao
nashibao / cf.coffee
Created April 9, 2017 06:56
crossfilter sample code
data = [{fld1: 'type1', fld2: 10},...]
cf = crossfilter(data)
# create dimension
dim1 = cf.dimension (d) -> return d.fld1
dim2 = cf.dimension (d) -> return d.fld2
# create group
group = dim2.group (fld2) -> return fld2 % 5
@nashibao
nashibao / blog4.sql
Last active November 30, 2016 14:22
blog4.sql
SELECT hoge FROM a
JOIN
(SELECT fuga FROM b GROUP BY fuga) AS c
ON a.hoge = c.fuga
@nashibao
nashibao / blog3.sql
Created November 30, 2016 14:18
blog3.sql
SELECT hoge FROM a
JOIN
(SELECT fuga FROM b) AS c
ON a.hoge = c.fuga
@nashibao
nashibao / blog2.sql
Created November 30, 2016 14:17
blog2.sql
SELECT corpus, word, SUM(word_count) AS total FROM tbl
WHERE ...
Group By corpus
ORDER BY total
DESC LIMIT 5
@nashibao
nashibao / blog1.sql
Last active November 30, 2016 14:14
blog1
SELECT corpus, word, word_count FROM tbl
WHERE LENGTH(word) > 4
ORDER BY word_count
DESC LIMIT 5
from os.path import realpath
import sys
import numpy as np
from numpy.random import rand
from numpy import matrix
from numpy import multiply
from pyspark import SparkContext
LAMBDA = 0.01 # regularization for als
@nashibao
nashibao / dnode_performance.coffee
Created April 17, 2014 09:47
dnode performance.
dnode = require 'dnode'
async = require 'async'
iteration_num = 100
# setup
server = dnode {
test: (a, b, cb)->
cb(null, a + b)
}
server.listen(8062)
@nashibao
nashibao / component_with_requirejs.md
Last active August 29, 2015 13:58
Makefile to make `component/component` working with `requirejs`.

I found some modules of component/component (ex: lodash) may cause a problem with AMD module loader like requirejs.
You should delete locally the define property to make a component working nicely with these loaders.

like below..

install: components index.js
	component build --standalone app --out . --name app-temp
	sed -e "s/;(function(){/;(function(){var define = undefined;/g" app-temp.js > app.js