Skip to content

Instantly share code, notes, and snippets.

Avatar
🍵

Shuhei Kagawa shuhei

🍵
View GitHub Profile
View gulp-require-bundle.js
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) {
View gist:9635191
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
A projection setting file for vim-rails.
View projections.json
{
"app/services/*.rb": {
"command": "service"
},
"app/workers/*.rb": {
"command": "worker"
},
"app/assets/javascripts/models/*.js.coffee": {
"command": "jmodel"
},
View js-modules.markdown

JS Modules

  • RequireJS
  • CommonJS
  • ES6 Modules

Why modules?

  • Divide et impera
  • Avoid global variables
@shuhei
shuhei / gulp-error-handling.md
Last active Aug 29, 2015
Gulp error handling
View gulp-error-handling.md

Gulp error handling

Orchestrator ignores stream errors

gulp uses orchestrator to run tasks. orchestrator ignores error events of stream that task function returns. https://github.com/orchestrator/orchestrator/pull/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

View clone-ec2-windows-instance.md

EC2 Windows Instance のクローン

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

パスワードの再設定。

@shuhei
shuhei / colike.js
Created Jul 2, 2014
Super simple implementation of something like co
View colike.js
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 Jul 24, 2014
Extract color palette of Google's Material Design. Run on http://www.google.com/design/spec/style/color.html
View palette.js
// 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 Jul 29, 2014
CSV to something
View transform.js
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];
You can’t perform that action at this time.