Skip to content

Instantly share code, notes, and snippets.

View satoryu's full-sized avatar
🤘
Put your 🦊 up!

Tatsuya Sato satoryu

🤘
Put your 🦊 up!
View GitHub Profile
# stolen from http://github.com/cschneid/irclogger/blob/master/lib/partials.rb
# and made a lot more robust by me
# this implementation uses erb by default. if you want to use any other template mechanism
# then replace `erb` on line 13 and line 17 with `haml` or whatever
module Sinatra::Partials
def partial(template, *args)
template_array = template.to_s.split('/')
template = template_array[0..-2].join('/') + "/_#{template_array[-1]}"
options = args.last.is_a?(Hash) ? args.pop : {}
options.merge!(:layout => false)
@woodie
woodie / README.markdown
Created March 14, 2010 08:25
Deferred Dispatcher

The DeferredDispatcher is a way to get around the 30-second limit for App Engine requests. We don't want spin-up to be a "show stopper", and we want every request to have a full 30 seconds to do "real work". We added this to appengine-rack 0.0.7, so folks won't need an additional require. The DeferredDispatcher works by using redirects to break up a loading request into 3 parts.

  1. initialize the jruby runtime and jruby-rack
  2. require the framework, and create a new dispatcher
  3. process the real request, with a full 30 seconds

We are inside jruby-rack, so obviously the runtime and Jruby-rack have initialized, so first we set @runtime to true (from nil) and redirect. Next pass, we notice that the @rack_app is nil, so we require the framework (which can take some time) and create a new dispatcher (these have been passed in as a hash) and redirect. In the final pass, we hand the environment to the dispatcher, to do the original "work" of the request.

#!/usr/bin/env ruby
##
# script/spec_server_irb
require 'drb'
require 'irb'
begin
begin
anonymous
anonymous / watts_json.py
Created March 22, 2011 03:47
tepcoの画像データから現在の電力を計算してjsonにして出力 http://s1.fukuda.org/watts/watts.json で確認可能
#!/bin/env python
import Image
import urllib
import datetime
import json
import os
class Watts(object):
def __init__(self):
@BanzaiMan
BanzaiMan / Abstract.md
Created December 5, 2011 04:47
RubySpec を走らせる

RubySpec とは

RubySpec は Ruby で動くコードによって Ruby そのものの挙動を記述しようとするテストの集まりです。詳しくは http://rubyspec.org

これを動かしてみましょう。

RubySpec をクローンする。

git clone git://github.com/rubyspec/rubyspec.git

RubySpec を動かす為のライブラリである mspec をクローンする。

@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@ayumin
ayumin / git-dojo.md
Created March 2, 2012 10:59
Git道場実行委員募集

Git道場実行委員募集

3月下旬~4月くらいにGit道場を開催したいと思います。

講義メインではなくてなるべく手を動かす時間をたくさんとり、参加者全員が”怖がらずにmerge/rebaseをできるようになる”というのが目標です。

このイベントに実行委員として参加してくれる方は、下記の形式のメールを送信してください。

To: git-dojo_at_qwik.jp

Cc: ayumu.aizawa_at_gmail.com

@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active June 20, 2024 12:25
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jugyo
jugyo / gist:3662942
Created September 7, 2012 03:55
getting profile for rails
def prof(&block)
result = RubyProf.profile(&block)
filename = "result-#{Time.now.to_i}.html"
File.open(filename, 'w') do |file|
RubyProf::FlatPrinter.new(result).print(file, :min_percent => 1)
end
puts "=> #{filename}"
end
# Load the rails application
@sorah
sorah / gist:7803201
Last active December 30, 2015 08:29 — forked from hsbt/gist:7719305