Skip to content

Instantly share code, notes, and snippets.

Avatar

Kensuke Nagae kyanny

View GitHub Profile
@fujimura
fujimura / README.md
Created May 11, 2012
heroku_config.rake
View README.md

ローカルのomniauth.ymlにheroku用の設定を書いておいて、

$ rake heroku_config:upload

すればherokuに設定がコピーされます。

@zbskii
zbskii / gist:3699880
Created Sep 11, 2012
Ruby allocations
View gist:3699880
require 'rubygems'
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::ALLOCATIONS
RubyProf.start
1_000_000.times{ Array.new(10) }
result = RubyProf.stop
# Print a flat profile to text
printer = RubyProf::FlatPrinter.new(result)
printer.print(STDOUT)
@kyanny
kyanny / config.ru
Created Sep 12, 2012
デモアプリ of Sapporo Ruby Kaigi Pre Event in Tokyo
View config.ru
require 'rack'
class App
def call(env)
html = %Q!<html><body style="margin:0"><img src="http://30d.jp/img/kyanny/public/80a57ec4-fc89-11e1-9cd3-00262d09affa_original.jpg" /></body></html>!
[200, {'content-type' => 'text/html'}, [html]]
end
end
run App.new
View app.js
console.log('hi');
window.Todos = Ember.Application.create();
Todos.Todo = Ember.Object.extend({
title: null,
isDone: false
});
Todos.todosController = Ember.ArrayController.create({
content:[],
View gist:3888103
// NSString* url = [NSString stringWithFormat:@"http://api.twitter.com/1/users/profile_image?size=normal&screen_name=%@", [screenName gtm_stringByEscapingForURLArgument]];
NSString *url = [NSString stringWithFormat:@"http://n.hatena.ne.jp/%@/profile/image?type=face", screenName]; // はてなのURLに変更
View detect_invalid_enc.rb
#!/usr/bin/env ruby
while ARGF.readline
puts $.
begin
$_.match /./
rescue => e
puts $_
raise e
end
View gist:4001702
CONFIGURE_OPTS="--with-out-ext=tk,tk/* --with-opt-dir=`brew --prefix openssl`:`brew --prefix readline`" rbenv install 2.0.0-dev
View application_controller.rb
class ApplicationController < ActionController::Base
# see also: http://stackoverflow.com/questions/2385799/how-to-redirect-to-a-404-in-rails
def not_found!
raise ActionController::RoutingError.new('Not Found')
end
end
@riywo
riywo / bashrc
Created Dec 12, 2012
setting hostname as screen window title
View bashrc
export PS1='\[\033k'"$HOSTNAME"'\033\\\]'"$PS1"
@sasimpson
sasimpson / gist:1112739
Created Jul 28, 2011
Ruby Net:HTTP chunked transfer
View gist:1112739
require 'uri'
require 'net/http'
class Chunked
def initialize(data, chunk_size)
@size = chunk_size
if data.respond_to? :read
@file = data
end
end