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 / debug.m
Created July 19, 2012 23:39
DEBUG or not
#if DEBUG
NSLog(@"development mode");
#else
NSLog(@"production mode");
#endif
@ppworks
ppworks / routes.rb
Created July 15, 2012 11:45
routes for users
My::Application.routes.draw do
resources :users, :only => [:show] do
resources :followings, :only => [:index]
resources :followers, :only => [:index]
resources :groups, :only => [:index]
end
end
@ppworks
ppworks / routes.rb
Created July 14, 2012 03:41
routes for current_user
My::Application.routes.draw do
# /my scope for current_user
scope :path => :my do
resources :followings, :only => [:index, :update, :destroy], :as => :my_followings
resources :followers, :only => [:index], :as => :my_followers
resources :feeds, :only => [:index], :as => :my_feeds
resources :groups, :only => [:index], :as => :my_groups do
member do
put :entry, :action => :join
@ppworks
ppworks / gist:3107537
Created July 13, 2012 21:17
Backbone.js で History.pushState未実装ブラウザでhash fragmentを使わずにそのままのurlを使う
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
@ppworks
ppworks / hoge.m
Created July 10, 2012 11:15
まじで断片ですまぬ
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
if (self.item_page == 1 && !JSON) {
[UIUtilitiy hideActivityIndicator];
[UIUtilitiy showAlert:@"error" text:@"見つかりませんでした"];
return;
}
if (JSON) {
[self.items addObjectsFromArray:[[[NSMutableArray alloc]initWithArray:JSON]autorelease]];
self.not_found = NO;
@ppworks
ppworks / UIUtilitiy.h
Created July 6, 2012 04:56
UIUtilitiy
#import <Foundation/Foundation.h>
@interface UIUtilitiy : NSObject
+ (void)showAlert: (NSString*)title text:(NSString*)text;
+ (void)showActivityIndicator:(UIViewController *)controller;
+ (void)hideActivityIndicator;
@end
@ppworks
ppworks / AccessTokenManager.h
Created July 6, 2012 04:52
facebook-ios-sdk sample
#import <Foundation/Foundation.h>
@interface AccessTokenManager : NSObject
@property (nonatomic, copy) NSString *facebookAccessTokenKey;
+ (AccessTokenManager *)sharedManager;
@end
@ppworks
ppworks / README.md
Created June 21, 2012 04:33
backbone data link
require 'spec_helper'
describe 'layouts/application' do
describe 'rendered application layout' do
subject { rendered }
context 'when body_class is setted ' do
before do
view.content_for(:body_class, 'test_class')
render
end
@ppworks
ppworks / Preferences.sublime-settings
Created June 4, 2012 06:55
Sublime Text2 settings
{
"color_scheme": "Packages/User/Railscasts.tmTheme",
"font_face": "Bitstream Vera Sans Mono",
"font_size": 14.0,
"ignored_packages": [""],
"vintage_start_in_command_mode": true,
"translate_tabs_to_spaces": true,
"vintage_ctrl_keys": true
}