Skip to content

Instantly share code, notes, and snippets.

View mackato's full-sized avatar

Masakuni Kato mackato

View GitHub Profile
@mackato
mackato / devise_preview.rb
Created March 10, 2014 08:45
Rails 4.1.0.rc1でdeviseのメールをプレビューする ref: http://qiita.com/mackato/items/3f1e8b78fc80164ddcd6
class DevisePreview < ActionMailer::Preview
def confirmation_instructions
Devise::Mailer.confirmation_instructions(User.new, Devise.friendly_token[0,20])
end
end
@mackato
mackato / have_store_accessor_matcher.rb
Last active December 25, 2015 11:59
Rails 4 Postgresql store accessor matcher
module Shoulda
module Matchers
module ActiveRecord
def have_store_accessor(key)
HaveStoreAccessor.new(key)
end
class HaveStoreAccessor
def initialize(key)
@key = key
@mackato
mackato / rbenv-1.8.7-bundle-install-libv8
Created August 9, 2012 15:58
rbenv exec bundle install with libv8 (1.8.7)
RUBYOPT="-r rubygems" rbenv exec bundle install --path vendor/bundle
@mackato
mackato / homebrew.mxcl.jenkins.plist
Created August 9, 2012 08:05
Jenkins plist for Mac OS X
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>homebrew.mxcl.jenkins</string>
<key>ProgramArguments</key>
<array>
<string>/usr/bin/java</string>
<string>-Dfile.encoding=UTF-8</string>
@mackato
mackato / create-daily-blog
Created March 30, 2012 09:19
日報起動スクリプト
#!/bin/bash -e
NAME="YOUR JAPANESE LAST NAME"
DATE=`date '+%Y-%m-%d'`
URL="https://airshq.atlassian.net/wiki/pages/createblogpost.action?spaceKey=AIRS&title=$DATE+$NAME"
open $URL
@mackato
mackato / filter_with_module.rb
Created March 26, 2012 07:15
declare filter when module is included
module Foo
def self.included(base)
base.class_eval do
before_filter :admin_required
end
end
end
@mackato
mackato / add_git_remote_repository.sh
Created February 14, 2012 04:13
add git remote repository
git remote add origin my://server/repo.git
git config branch.master.remote origin
git config branch.master.merge refs/heads/master
@mackato
mackato / mapview_contains_location.m
Created January 25, 2012 02:07
Check MKMapView contains CLLocationCoordinate2D
MKCoordinateRegion region = mapView.region;
CLLocationCoordinate2D topLeftCoordinate =
CLLocationCoordinate2DMake(region.center.latitude + (region.span.latitudeDelta / 2.0),
region.center.longitude - (region.span.longitudeDelta / 2.0));
CLLocationCoordinate2D bottomRightCoordinate =
CLLocationCoordinate2DMake(region.center.latitude - (region.span.latitudeDelta / 2.0),
region.center.longitude + (region.span.longitudeDelta / 2.0));
MKMapPoint topLeftMapPoint = MKMapPointForCoordinate(topLeftCoordinate);
@mackato
mackato / twitter-bootstrap-rails-demo.md
Created December 18, 2011 00:59
Twitter Bootstrap for Rails Demo

Twitter Bootstrap Demo

% rails new demoapp
% cd demoapp
% rails g scaffold post title:string body:text published_at:datetime draft:boolean
% rake db:migrate

class Post < ActiveRecord::Base
	validates :title, :presence => true

validates :body, :presence => true

@mackato
mackato / consumer.py
Created July 8, 2011 02:10
Config files for hamamatsurb-bot.
KEY = "YOUR_TWITTER_APP_CONSUMER_KEY"
SECRET = "YOUR_TWITTER_APP_CONSUMER_SECRET"
IGNORE_SOURCES = ["hamamatsurb-bot"]