Skip to content

Instantly share code, notes, and snippets.

View oshikryu's full-sized avatar

Ryuta Oshikiri oshikryu

  • San Francisco, CA
View GitHub Profile
@oshikryu
oshikryu / csvtostring.coffee
Created January 27, 2014 21:30
convert csv string to file download
window.URL = window.URL || window.webkitURL
blob = new Blob([csvString], {type: 'text/plain'})
objectURL = window.URL.createObjectURL(blob)
@$el.find('.confirm').parent().attr("href", window.URL.createObjectURL(blob))
@$el.find('.confirm').parent().attr("download", @_checkFileName())
@oshikryu
oshikryu / resize.coffee
Created January 30, 2014 19:19
resize legend based on width and bbox pos
_spaceLines: ->
keys = d3.selectAll('.key')[0]
extraRows = 0
_lineSpacer = (d, i) =>
keyPos = keys[i].getBBox().x
keyEdge = keyPos + keys[i].getBBox().width
edge = @w - @m*2
@oshikryu
oshikryu / rowarrayblanks.coffee
Created February 4, 2014 18:14
Fill row array blanks in table
_fillRowArrayBlanks: ->
curLen = @displayedArray.length
diff = @watchSamples - curLen
filler = []
for i in [0...diff]
filler[i] = [
point: '-'
pinned: true
]
@oshikryu
oshikryu / renderlegend.coffee
Created February 6, 2014 23:48
renders a legend given a quantile scale of colors
@colorScale = d3.scale.quantile()
.domain([0, .01, .1, .2, .3, .5, .8, 1.3, 2.1, 3.3])
.range(@colors)
_renderLegend: ->
# quantizes colors and adds an extra 0
_legendData = [0].concat(@colorScale.quantiles())
_legendData.unshift(0)
w next word
e end of word
b is back a word
dd line
split buffer
ctr +l w + v
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@oshikryu
oshikryu / app.js
Created April 28, 2015 21:42
sample ember
App = Ember.Application.create();
App.Router.map(function() {
this.resource('all');
this.resource('recent');
this.resource('starred');
});
App.IndexRoute = Ember.Route.extend({
beforeModel: function() {
@oshikryu
oshikryu / notes.md
Created April 28, 2017 18:49
JAMstack notes

JAMstack notes


Netlify structure:

Structured data in a git repository

Smashing architecture React talking to github api Victor hugo go based boilerplate static site generator

@oshikryu
oshikryu / datamaker.js
Last active May 2, 2017 00:03
CSV export with webworkers
// this file expects global variables data and compareData to be available
var regData = data;
var doubleData = data.concat(data);
var doubleCompareData = compareData.concat(compareData);
var millionData = [];
for (var idx=0; idx < 10; idx += 1) {
millionData = millionData.concat(doubleCompareData);
}
@oshikryu
oshikryu / attachments.js
Last active September 27, 2017 18:12
getting attachments in two ways
/*
Which implementation would you prefer for downloading bulk attachments? (e.g. click download and
expect 3+ images)
1) One implementation requires the addition of 3 new libraries to make a zip file (which a user will just unzip
anyway)
However, it looks pretty straightforward
*/