Skip to content

Instantly share code, notes, and snippets.

View ppworks's full-sized avatar
🏠
Working from home

Naoto Koshikawa ppworks

🏠
Working from home
View GitHub Profile
@ppworks
ppworks / ranking.rb
Created September 27, 2012 09:41
配列の要素をランキングする
#!/usr/bin/env ruby
def ranks scores
ranks = Array.new scores.size, 1
prev = nil
rank = 0
scores.each_with_index do|score, i|
unless prev == score
rank = i
end
@ppworks
ppworks / notification.m
Created August 21, 2012 11:01
Syntax-aware indenting
[[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(receiveShouldStartLoad:)
name: @"shouldStartLoad"
object: nil];
@ppworks
ppworks / gist:3388492
Created August 18, 2012 17:16
UIWebView crash log
'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]:
 attempt to insert nil value (key: WebKitLocalStorageDatabasePathPreferenceKey)'
@ppworks
ppworks / webviwe_bounce.m
Created August 16, 2012 06:46
UIWebViewをバウンスさせない
id subview = [[_webView subviews] objectAtIndex:0];
if([[subview class] isSubclassOfClass:[UIScrollView class]]){
((UIScrollView *)subview).bounces = NO;
}
@ppworks
ppworks / module.rb
Created August 13, 2012 04:06
controller module
module Modules::Groups
def self.included base
if true
base.skip_filter
end
end
end
@ppworks
ppworks / piyopiyo.rb
Created August 11, 2012 03:32
PiyoPiyo
class PiyoPiyo
end
@ppworks
ppworks / rake routes
Created August 7, 2012 13:37
routes.rb
search_reservation_departure GET /reservation/departure(.:format) departures#search {:destination=>/\w+/}
reservation_departure GET /reservation/departure(.:format) departures#show
search_reservation_arrival GET /reservation/arrival(.:format) arrivals#search {:source=>/\w+/}
reservation_arrival GET /reservation/arrival(.:format) arrivals#show
new_reservation GET /reservation/new(.:format) reservations#new
@ppworks
ppworks / hoge.rb
Created August 1, 2012 08:58
hoge.rb
user = User.where(name: params[:name]).first
return unless user.present?
main_blog = user.main_blog
return unless main_blog.present?
@ppworks
ppworks / routes.rb
Created July 26, 2012 09:38
routes.rb resourcesの入れ子
My::Application.routes.draw do
resources :groups do
resources :tasks
end
end
@ppworks
ppworks / setup.coffee.js
Created July 21, 2012 11:07
pushState未サポート時にhash fragmentを使わない設定
window.App =
Models: {}
Collections: {}
Views: {}
Routers: {}
init: (options)->
options = {} unless options
options.pushState = true
options.hashChange = false # don't want to rewrite /pathname to #pathname