Skip to content

Instantly share code, notes, and snippets.

@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) {
@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:
  • npm
    • grunt
    • uglify
    • bower
    • n
  • ユーティリティ
    • lo-dash
    • Q
    • underscore.js
  • マルチメディア
@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
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.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)
@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 / 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 / gist:9449924
Created March 9, 2014 16:01
画像がロードされてなかったら終わるまで一時的にロード中画像に差し替える
$(function() {
$('.lens-image').each(function() {
var img = this
, src = this.src
, loader = new Image;
if (!this.complete || (!img.naturalWidth === 0)) {
img.src = './img/animation.gif';
loader.src = src;
loader.onload = function() {
convert -resize 323x323 -unsharp 2x1.4+0.5+0 hoge.png fuga.png