Skip to content

Instantly share code, notes, and snippets.

View mackato's full-sized avatar

Masakuni Kato mackato

View GitHub Profile
@mackato
mackato / solo.rb
Created February 20, 2011 17:37
chef-solo configuration file. /etc/chef/solo.rb
file_cache_path "/tmp/chef-solo"
cookbook_path "#{ENV['HOME']}/chef-repo/cookbooks"
role_path "#{ENV['HOME']}/chef-repo/roles"
class TestFinally {
int num;
public static void main(String[] args) {
TestFinally test = new TestFinally();
int ret = test.increment();
assert ret == 1;
assert test.num == 2;
System.out.println("Done.");
}
require 'open-uri'
begin
open('http://onlineshop.mb.softbank.jp/ols/html/model/ipad/')
`say "iPad2 online shop page opened!"`
rescue Exception => e
unless e.to_s =~ /^403/
`say "iPad2 online shop status changed #{e}"`
end
end
#logo
margin-top: 30px
color: #c00
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif
letter-spacing: -1px
font-weight: bold
<!doctype html>
/[if lt IE 7 ] <html class="ie ie6" lang="en">
/[if IE 7 ] <html class="ie ie7" lang="en">
/[if IE 8 ] <html class="ie ie8" lang="en">
/ [if (gte IE 9)|!(IE)]><!
%html{:lang => "en"}
/ <![endif]
%head
%meta{:charset => "utf-8"}
%title= yield :title
@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"]
@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 / 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 / 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 / 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