Skip to content

Instantly share code, notes, and snippets.

View shuhei's full-sized avatar
🐶
This is fine

Shuhei Kagawa shuhei

🐶
This is fine
View GitHub Profile
var path = require('path');
var util = require('util');
var through = require('through2');
module.exports = function (filename) {
var contents = [];
var cwd = process.cwd();
var base = cwd;
function transform(file, encoding, cb) {
nkf -w --overwrite b_20140301.txt
grep "心筋梗塞" b_20140301.txt | cut -d "," -f 3,6 | sed -e 's/"//g' | sed -e 's/,/ /g' | less
@shuhei
shuhei / projections.json
Created May 7, 2014 07:56
A projection setting file for vim-rails.
{
"app/services/*.rb": {
"command": "service"
},
"app/workers/*.rb": {
"command": "worker"
},
"app/assets/javascripts/models/*.js.coffee": {
"command": "jmodel"
},
@shuhei
shuhei / where.md
Created May 16, 2014 05:03
Where to put models in Angular?

JS Modules

  • RequireJS
  • CommonJS
  • ES6 Modules

Why modules?

  • Divide et impera
  • Avoid global variables

EC2 Windows Instance のクローン

事前に元のインスタンスに設定が必要。 EC2Config の設定ファイルを編集する方法と、GUI から設定する方法がある。 今回は、設定ファイルで。/Program Files/Amazon/EC2Config/settings/config.xml を開く。 EC2SetPassword を Disabled -> Enabled にする。 このとき、GUI でシャットダウンせずに、普通にシャットダウンする。 GUI でやる場合は、GUI 上でパスワードの再設定するよう設定する。試してないが。

パスワードの再設定。

@shuhei
shuhei / gulp-error-handling.md
Last active August 29, 2015 14:02
Gulp error handling

Gulp error handling

Orchestrator ignores stream errors

gulp uses orchestrator to run tasks. orchestrator ignores error events of stream that task function returns. robrich/orchestrator#46

The author says that it is because the inconsistent implementations of gulp plugin streams. Some streams emit error event and emits end event later.

How it affects your task

@shuhei
shuhei / colike.js
Created July 2, 2014 14:55
Super simple implementation of something like co
function colike(genFunc) {
var gen = genFunc();
var thunk = gen.next().value;
function done() {
// We don't know the number of arguments.
var err = arguments[0];
var values = Array.prototype.slice.call(arguments, 1);
if (err) {
@shuhei
shuhei / palette.js
Created July 24, 2014 00:59
Extract color palette of Google's Material Design. Run on http://www.google.com/design/spec/style/color.html
// Create an Array from an Array-like Object such as NodeList.
function toArray(arrayLike) {
return Array.prototype.slice.call(arrayLike);
}
// Create an Object from an Array of objects.
function toObject(objects, keyName, valueName) {
return objects.reduce(function(acc, obj) {
acc[obj[keyName]] = obj[valueName];
return acc;
@shuhei
shuhei / transform.js
Created July 29, 2014 00:49
CSV to something
var data = [
['Prefecture', 'A', 'B', 'C'],
['Tokyo', '1', '2', '3'],
['Kanagawa', '4', '5', '6']
];
var labels = data[0];
var dataSet = data.slice(1).reduce(function(acc, row) {
var item = {};
item[labels[0]] = row[0];