Skip to content

Instantly share code, notes, and snippets.

View kyanny's full-sized avatar

Kensuke Nagae kyanny

View GitHub Profile
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
CONFIGURE_OPTS="--with-out-ext=tk,tk/* --with-opt-dir=`brew --prefix openssl`:`brew --prefix readline`" rbenv install 2.0.0-dev
#!/usr/bin/env ruby
while ARGF.readline
puts $.
begin
$_.match /./
rescue => e
puts $_
raise e
end
// 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に変更
@tatsuosakurai
tatsuosakurai / app.js
Created October 8, 2012 06:23
Emberjs Sample
console.log('hi');
window.Todos = Ember.Application.create();
Todos.Todo = Ember.Object.extend({
title: null,
isDone: false
});
Todos.todosController = Ember.ArrayController.create({
content:[],
@MichalPekala
MichalPekala / proxy.ru
Created September 27, 2012 12:24
Rack Proxy with HTTP Basic Authentication
require 'rubygems'
require 'rack/streaming_proxy'
use Rack::Auth::Basic, "Restricted Area" do |username, password|
[username, password] == ['user', 'password']
end
use Rack::StreamingProxy do |request|
if request.path.start_with?("/proxy")
"http://other.host#{request.path}"
@kyanny
kyanny / config.ru
Created September 12, 2012 03:40
デモアプリ of Sapporo Ruby Kaigi Pre Event in Tokyo
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
@zbskii
zbskii / gist:3699880
Created September 11, 2012 17:08
Ruby allocations
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)
@syou6162
syou6162 / Difference_between_cl_and_clojure.md
Created August 19, 2012 11:09
On Lispを読んでいて分からなかったCommon LispとClojureの違いについて自分なりにまとめていきます

Common Lispの関数

dolist

(dolist (var init-form result) S式 ... )

dolist は名前が示すように、リストに関係があります。最初に init-form を評価します。このとき、評価結果はリストでなければいけません。リスト以外の場合はエラーとなります。dolist は、このリストの要素を順番に変数 var に代入して S 式を評価します。リストの要素がなくなったら result を評価し、その値が dolist の返り値になります。次の例を見てください。