Skip to content

Instantly share code, notes, and snippets.

View chakrit's full-sized avatar

Chakrit Wichian chakrit

View GitHub Profile
class ApiController < ApplicationController
respond_to :json
class Pong < Object
attr_accessor :pong
def initialize
@pong = true
end
class ApiController < ApplicationController
respond_to :json
class Pong < Object
attr_accessor :pong
def initialize
@pong = true
end
CLLocationCoordinate2D min = CLLocationCoordinate2DMake(99999.0, 99999.0);
CLLocationCoordinate2D max = CLLocationCoordinate2DMake(-99999.0, -99999.0);
// find max/min....
// zoom to cover area
// TODO: Maybe better using a MKPolygon which can calculate its own fitting region.
CLLocationCoordinate2D center = CLLocationCoordinate2DMake((max.latitude + min.latitude) / 2.0, (max.longitude + min.longitude) / 2.0);
MKCoordinateSpan span = MKCoordinateSpanMake(max.latitude - min.latitude, max.longitude - min.longitude);
MKCoordinateRegion region = MKCoordinateRegionMake(center, span);
require 'spec_helper'
describe 'api' do
# routing
it 'should route to v1 /me correctly' do
assert_routing('/api/v1/me', { :controller => 'me', :action => 'show' });
end
# controllers
@chakrit
chakrit / CWView.h
Created February 13, 2012 05:57
Objective-C custom XIB-based UIView stub
#import <UIKit/UIKit.h>
@interface CWView : UIView
// for child class to override and change the behavior (if needed)
@property (nonatomic, readonly) BOOL useNib;
@end
config.autoload_paths += %W(#{config.root}/app/workers)
config.autoload_paths += %W(#{config.root}/app/presenters)
config.autoload_paths += %W(#{config.root}/lib/addresstalk/errors)
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib/addresstalk)
$ npm install
npm WARN gzip@0.1.0 package.json: bugs['web'] should probably be bugs['url']
npm WARN underscore.string@2.0.0 dependencies field should be hash of <name>:<ve
for (var i = 0; i < 10; i++) if ((function(i) {
return (i < 5) ? console.log(i) : true;
})(i)) break;
var unscoped = function(objName) {
return eval(objName);
};
var x = 111;
function newScope() {
var x = 222;
return unscoped('x');
};
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
Request timeout for icmp_seq 0
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=100.654 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=103.946 ms (DUP!)
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=105.836 ms (DUP!)
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=114.566 ms (DUP!)
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=115.913 ms (DUP!)
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=118.262 ms (DUP!)
64 bytes from 8.8.8.8: icmp_seq=1 ttl=46 time=125.349 ms (DUP!)