Skip to content

Instantly share code, notes, and snippets.

@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] というものがよく使われてた

# config/initializers/client_side_validations.rb
...
module SimpleForm
class FormBuilder
def self.client_side_form_settings(options, form_helper)
{type: 'SimpleForm::FormBuilder'}
end
end
end
@keikubo
keikubo / README.md
Created June 23, 2012 05:08
Rackhubでのウェブサーバーの起動方法 (Nginx)

ウェブサーバーの起動方法

Rackhubでは現在、デフォルトの状態ではウェブサーバーを特に起動させていません。何も操作をしていない状態だと以下のようなページが表示されます。

これは、Apache, Nginxなど、ユーザーが好きなウェブサーバーを必要に応じて立ち上げることができるようにするためです。なので、ウェブアクセスが必要な方は、適宜適当なサーバーを立ち上げてお使いください。

Rackhubには、Apache, Nginxなどの主要なサーバーがすぐに使用できる状態で、最初からインストールされています。ここではいくつかの主要なRackにインストール済みのサーバーの起動方法及び簡単な使い方について説明します。

@jugyo
jugyo / gist:2992584
Created June 26, 2012 01:33
render_haml helper
module ApplicationHelper
# Usage:
#
# render_haml <<-HAML, foo: "FOO"
# %p Hello #{foo}!
# HAML
#
def render_haml(template, locals = {})
engine = Haml::Engine.new(template.gsub(/^#{template[/^\s+/]}/, ''))
engine.render(self, locals)
@komiya-atsushi
komiya-atsushi / week_of_month.rb
Created August 6, 2012 01:57
指定された日付が、その月において何週目にあたるのかを計算する Ruby のメソッド
require 'date'
#
# 指定された日付が、その月において何週目にあたるのかを計算し、返却します。
#
# 週始まりは月曜です。初週を 1 としています。
#
def week_of_month(date)
first_week = (date - (date.day - 1)).cweek
this_week = date.cweek
@rosylilly
rosylilly / jquery-tapp.js
Created September 13, 2012 06:28
jQuery-tapp
jQuery.fn.extend({
/**
* $('li').tapp() で console.debug に this を出力します。
*
* func を与えることで、func(this) を実行した結果を console.debug に出力します。
*
* @this {jQuery}
* @param {function(jQuery)=} func
* @return {jQuery}
*/
@chocoby
chocoby / gist:3773724
Created September 24, 2012 01:25
shitajiki demo
$ curl http://shitajiki.herokuapp.com -X POST -d "data=# shitajiki \n寿司 :sushi:"
# <h1>shitajiki</h1>
#
# <p>寿司 <img src="http://shitajiki.herokuapp.com/emojis/sushi.png" width="20" height="20" title=":sushi:" alt=":sushi:" class="emoji" /></p>
@jugyo
jugyo / RubyTest.sublime-settings
Created October 16, 2012 02:50
RubyTest.sublime-settings for zeus
{
"run_rspec_command": "zeus rspec {relative_path}",
"run_single_rspec_command": "zeus rspec {relative_path} -l{line_number}"
}
@hayajo
hayajo / changelog_en.md
Last active April 1, 2025 14:37
ChangeLog を支える英語

ChangeLog を支える英語

ChangeLog を書く際によく使われる英語をまとめました。

ほとんど引用です。

基本形

@a-suenami
a-suenami / README.md
Created November 8, 2012 04:56
git-branch-log.sh

使い方

任意のディレクトリにダウンロードして、以下のコマンドを実行する。

./git-branch-log.sh <merge_commit>