Skip to content

Instantly share code, notes, and snippets.

View kyamaguchi's full-sized avatar

kyamaguchi kyamaguchi

View GitHub Profile
# Para salvar a altura e largura das imagens enviadas pelo plugin paperclip, utilize o callback abaixo
#
# class Document < ActiveRecord::Base
#
# has_attached_file :document, :styles => { :medium => "300x300>" }
#
# before_save :save_dimensions
#
# def save_dimensions
# if document.image?
@oukayuka
oukayuka / inputmode.rb
Created July 23, 2009 09:03
Setting default input mode to text form for mobile client.
module ActionView
module Helpers
module FormHelper
alias :text_field_without_inputmode :text_field
# ==== Options
# * <tt>:inputmode</tt> - 入力モード。Jpmobile::InputMode::HIRAGANA-全角ひらがな、Jpmobile::InputMode::HANKAKUKANA-半角カナ、Jpmobile::InputMode::ALPHABET-半角英字、Jpmobile::InputMode::NUMERIC-半角数字
# ==== Examples
# text_field_tag(:user, :name, :size => 20, :inputmode => Jpmobile::InputMode::HIRAGANA)
# # => <input id="name" name="name" type="text" size="20" istyle="1" style="-wap-input-format:&quot;&lt;ja:h&gt;&quot;">
@visnup
visnup / posts_controller.rb
Created February 14, 2010 02:00
a scaffold using respond_with
class PostsController < ApplicationController
respond_to :html, :xml, :json
# GET /posts
# GET /posts.xml
def index
@posts = Post.paginate :page => params[:page]
respond_with @posts do |format|
format.atom
end
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@massive
massive / locale_diff.rb
Created November 29, 2010 13:51
Compares two YAML locale files and displays the difference
# Run: curl https://gist.github.com/raw/719970/locale_diff.rb | ruby - en fi
require 'rubygems'
require 'yaml'
l1 = ARGV[0]
l2 = ARGV[1]
first = YAML.load_file(l1 + ".yml")
second = YAML.load_file(l2 + ".yml")
def diff(root, compared, structure = [])
@ryanb
ryanb / favorite_gems.md
Created March 4, 2011 17:31
A list of my favorite gems for various tasks.
@pvdb
pvdb / deploy.md
Created March 13, 2011 10:09
Capistrano start/stop/restart tasks for Phusion Passsenger Standalone

With the introduction of Phusion Passenger Standalone, some of the established wisdom with regards to Capistrano tasks for managing Passenger are a tad outdated.

In particular, the start and stop tasks for Passenger are typically NOOPs, and only the restart task is deemed relevant. This is arguably no longer the case for standalone Passenger, where start and stop tasks do make sense, as they did back in the mongrel days.

The following Capistrano tasks illustrate how to start, stop and restart a standalone Passenger setup.

These tasks are for a Passenger setup that uses Unix domain sockets, but they can easily be modified for Passenger instances configured for TCP sockets.

    namespace :deploy do

task :start, :roles => :app, :except => { :no_release => t

@MyArtChannel
MyArtChannel / development.rb
Created April 25, 2011 20:42
Use Pry as IRB replacement in rails 3 console
# Add this to the end of your development.rb and add
#
# gem 'pry'
#
# to your Gemfile and run bundle to install.
silence_warnings do
begin
require 'pry'
IRB = Pry
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 17, 2024 14:20
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@moroya
moroya / aitter.js
Last active December 18, 2015 00:39
Amazon ikuratukatter
(function(){
var total = {};
var year = '2012';
var all = false;
function init(num) {
if(typeof num !== 'number') {
num = 0;
$('<div/>').css({
position: 'fixed',
left: 0,