Skip to content

Instantly share code, notes, and snippets.

@hadashiA
hadashiA / gist:4353436
Last active September 2, 2016 05:50
launch instance for knife-ec2
#USAGE: knife ec2 server create (options)
# -Z, --availability-zone ZONE The Availability Zone
# -A, --aws-access-key-id KEY Your AWS Access Key ID
# -K SECRET, Your AWS API Secret Access Key
# --aws-secret-access-key
# --user-data USER_DATA_FILE The EC2 User Data file to provision the instance with
# --bootstrap-version VERSION The version of Chef to install
# -N, --node-name NAME The Chef node name for your new node
# --server-url URL Chef Server URL
@hadashiA
hadashiA / file0.txt
Last active March 4, 2016 08:29
Elasticsearchを使ってレコメンデーションする ref: http://qiita.com/hadashiA/items/9a418df95f8611c041a2
$ plugin --url 'https://github.com/f-kubotar/elasticsearch-flavor/releases/download/v0.0.2/elasticsearch-flavor-0.0.3.zip' --install flavor
@hadashiA
hadashiA / gist:8649686
Created January 27, 2014 14:40
一本のReadableStreamを、二本のReadableStreamにする
fs = require 'fs'
gm = require 'gm'
im = gm.subClass imageMagick: true
{PassThrough} = require 'stream'
stream = fs.createReadStream '/Users/hadashi/tmp/20.png'
stream2 = new PassThrough
stream3 = new PassThrough
@hadashiA
hadashiA / brunch_server.coffee
Created November 17, 2013 14:34
Grunt止めて、mincer止めて、Brunchに乗り換えた ref: http://qiita.com/hadashiA/items/9f5fb4134bf87a560b82
{exists} = require('fs')
{EventEmitter} = require('events')
{resolve, join} = require('path')
{filter} = require('async')
http = require('http')
cordell = require('cordell')
{config} = require('./config')
class BrunchServer extends EventEmitter
@hadashiA
hadashiA / file0.cpp
Created October 19, 2013 16:37
c++11のlambdaでイベントハンドラ ref: http://qiita.com/hadashiA/items/3c3c10f9596c8f5fcdc9
#include <iostream>
#include <functional>
#include <string>
#include <map>
#include <vector>
using namespace std;
struct Event {
Event(const string& name, int data)
XCODEROOT = %x[xcode-select -print-path].strip
SIM_SYSROOT = "#{XCODEROOT}/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/"
DEVICE_SYSROOT = "#{XCODEROOT}/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/"
MRuby::Build.new do |conf|
toolchain :gcc
conf.gembox 'default'
end
@hadashiA
hadashiA / file0.txt
Created June 23, 2013 07:15
OSX10.8 で、Pythonのbzrlib がみつからない問題 ref: http://qiita.com/hadashiA/items/8fe63889bebac7e26dda
$ brew install emacs --HEAD --cocoa
==> Cloning bzr://http://bzr.savannah.gnu.org/r/emacs/trunk
bzr: ERROR: Couldn't import bzrlib and dependencies.
Please check the directory containing bzrlib is on your PYTHONPATH.
Traceback (most recent call last):
File "/usr/local/bin/bzr", line 74, in <module>
import bzrlib
ImportError: No module named bzrlib
Error: Failure while executing: /usr/local/bin/bzr checkout --lightweight http://bzr.savannah.gnu.org/r/emacs/trunk /Library/Caches/Homebrew/emacs--bzr
  • npm
    • grunt
    • uglify
    • bower
    • n
  • ユーティリティ
    • lo-dash
    • Q
    • underscore.js
  • マルチメディア
@hadashiA
hadashiA / gist:5504659
Created May 2, 2013 19:20
weak_ptr をキーにしたハッシュ
#include <memory>
#include <iostream>
#include <string>
#include <unordered_map>
#include <unordered_set>
using namespace std;
class Node {
public:
@hadashiA
hadashiA / file0.txt
Created March 9, 2013 15:55
expressのreq.format()を、urlの拡張子で判別してくれるようにする ref: http://qiita.com/items/e14e4eb1e6d748af15c4
app.get('/hoge.:format', function(req, res) {
res.format({
json: function(req, res) {
res.send({a: 1});
},
html: function(req, res) {
// ブラウザから /index.json にアクセスしてもこっちが実行される
res.render('index');
},
default: function(req, res) {