Skip to content

Instantly share code, notes, and snippets.

Avatar

Masakuni Kato mackato

View GitHub Profile
@mackato
mackato / devise_preview.rb
Created Mar 10, 2014
Rails 4.1.0.rc1でdeviseのメールをプレビューする ref: http://qiita.com/mackato/items/3f1e8b78fc80164ddcd6
View devise_preview.rb
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 Dec 25, 2015
Rails 4 Postgresql store accessor matcher
View have_store_accessor_matcher.rb
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 Aug 9, 2012
rbenv exec bundle install with libv8 (1.8.7)
View rbenv-1.8.7-bundle-install-libv8
RUBYOPT="-r rubygems" rbenv exec bundle install --path vendor/bundle
@mackato
mackato / homebrew.mxcl.jenkins.plist
Created Aug 9, 2012
Jenkins plist for Mac OS X
View homebrew.mxcl.jenkins.plist
<?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 Mar 30, 2012
日報起動スクリプト
View create-daily-blog
#!/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 Mar 26, 2012
declare filter when module is included
View filter_with_module.rb
module Foo
def self.included(base)
base.class_eval do
before_filter :admin_required
end
end
end
View add_git_remote_repository.sh
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 Jan 25, 2012
Check MKMapView contains CLLocationCoordinate2D
View mapview_contains_location.m
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 Dec 18, 2011
Twitter Bootstrap for Rails Demo
View twitter-bootstrap-rails-demo.md

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 Jul 8, 2011
Config files for hamamatsurb-bot.
View consumer.py
KEY = "YOUR_TWITTER_APP_CONSUMER_KEY"
SECRET = "YOUR_TWITTER_APP_CONSUMER_SECRET"
IGNORE_SOURCES = ["hamamatsurb-bot"]