Skip to content

Instantly share code, notes, and snippets.

View hanachin's full-sized avatar
🌺
OKA

Seiei Miyagi hanachin

🌺
OKA
View GitHub Profile
@bmabey
bmabey / env.rb
Created June 4, 2009 01:09
how to get spork working for cucumber in a rails app
require 'rubygems'
require 'spork'
Spork.prefork do
# Sets up the Rails environment for Cucumber
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'webrat'
@isaacs
isaacs / comma-first-var.js
Created April 6, 2010 19:24
A better coding convention for lists and object literals in JavaScript
// See comments below.
// This code sample and justification brought to you by
// Isaac Z. Schlueter, aka isaacs
// standard style
var a = "ape",
b = "bat",
c = "cat",
d = "dog",
# In your test_helper.rb
class ActiveRecord::Base
mattr_accessor :shared_connection
@@shared_connection = nil
def self.connection
@@shared_connection || retrieve_connection
end
end
@andruby
andruby / deploy.rb
Created January 26, 2011 19:48
Start and Stop tasks for resque workers, with capistrano deploy hook (without God)
after "deploy:symlink", "deploy:restart_workers"
##
# Rake helper task.
# http://pastie.org/255489
# http://geminstallthat.wordpress.com/2008/01/27/rake-tasks-through-capistrano/
# http://ananelson.com/said/on/2007/12/30/remote-rake-tasks-with-capistrano/
def run_remote_rake(rake_cmd)
rake_args = ENV['RAKE_ARGS'].to_s.split(',')
cmd = "cd #{fetch(:latest_release)} && #{fetch(:rake, "rake")} RAILS_ENV=#{fetch(:rails_env, "production")} #{rake_cmd}"
@nyuichi
nyuichi / Event.java
Created April 4, 2011 15:23
Spriteライブラリを自作してみた。
package sprite;
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class Event {
private static Queue<AWTEvent> queue = new LinkedList<AWTEvent>();
public static AWTEvent peek() {
return queue.peek();
@tyok
tyok / rspec_custom_matcher_capybara.rb
Created November 28, 2011 08:12 — forked from yosemsweet/rspec_custom_matcher_capybara.rb
Capybara matchers in RSpec custom matcher
RSpec::Matchers.define :have_widget_elements_for do |widget|
match do |actual|
puts actual.to_yaml
@errors = {}
expected_elements = {
:widget => ".widget",
:content_type => ".#{widget.content_type}",
:body => ".body",
:title => ".title",
@yuroyoro
yuroyoro / pre-commit.keyword-check.sample
Created March 16, 2012 04:27
特定のキーワードが含まれたらcommitさせないgit-hook
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
@tdkn
tdkn / gist:2292630
Created April 3, 2012 14:51
.emacs (自分用)
;; load-path の設定
(setq load-path (append '("~/.emacs.d/elisp/"
"/usr/share/emacs23/site-lisp/ibus/"
"~/.emacs.d/elisp/twittering-mode/")
load-path))
;; ============================================
;; 見た目の設定
;; ============================================
;; ツールバーを表示しない
@tdkn
tdkn / .zshrc
Created April 16, 2012 15:16
.zshrc (自分用)
# ============================================================
## 文字列 "^[" は実際にはエスケープなので置換しないと動かないよ。
#
## Emacs の場合:
# M-x replace-string RET C-q ESC RET ^[ RET とすれば置換。
#
## Vim の場合:
# :%s/\^\[/Ctrl+v ESC/gc とすれば置換。
# ============================================================
@rummelonp
rummelonp / faraday.md
Last active May 20, 2022 12:23
Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

Ruby の HTTP クライアントライブラリ Faraday が便利そう

API ラッパの開発には [RestClient gem][rest_client_gem] だとか
OAuth の必要なものは [Net/HTTP][net_http] + [OAuth gem][oauth_gem] を使ってた

[Twitter gem][twitter_gem] や [Instagram gem][instagram_gem] など API ライブラリのソースを読んでみると
[Faraday gem][faraday_gem] というものがよく使われてた