This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Newbie Programmer | |
def factorial(x) | |
if x == 0 | |
return 1 | |
else | |
return x * factorial(x - 1) | |
end | |
end | |
puts factorial(6) | |
puts factorial(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http { | |
... | |
server { | |
listen 80; | |
server_name myapp.com; | |
root /myapp/public; | |
passenger_enabled on; | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rack-legacy' | |
app = proc do |env| | |
use Rack::Legacy::Php, 'public' | |
end | |
run app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Offer < ActiveRecord::Base | |
belongs_to :offer_type | |
belongs_to :offer_rate | |
belongs_to :city | |
belongs_to :location | |
... | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)copyItems:(id)sender { | |
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; | |
NSMutableArray *items = [NSMutableArray arrayWithCapacity:_selectionView.selection.count]; | |
for (TTShapeModelObject *shp in _selectionView.selection) { | |
[item setObject:[NSKeyedArchiver archivedDataWithRootObject:shp] forKey:@"TTShapeModelObject"]; | |
[items addObject:item]; | |
} | |
pasteboard.items = items; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Set non ARC flag (-fno-objc-arc) for the execution file | |
// http://stackoverflow.com/questions/6646052/how-can-i-disable-arc-for-a-single-file-in-a-project | |
// | |
// | |
NSMutableArray *mutableArrayOrginal = [NSMutableArray arrayWithObjects:@"asdasd", nil]; | |
NSLog(@"mutableArrayOrginal address is: %p", mutableArrayOrginal); | |
NSMutableArray *mutableArrayCopy = [mutableArrayOrginal copy]; | |
NSLog(@"mutableArrayCopy address is: %p", mutableArrayCopy); | |
if ([mutableArrayOrginal isEqual:mutableArrayCopy]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:1]; | |
NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"]; | |
NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]]; | |
Class callerClass = NSClassFromString([array objectAtIndex:3]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
NSMutableArray *resources = [[NSMutableArray alloc] init]; | |
NSURL *URL = [NSURL URLWithString:@"http://localhost:8080"]; | |
AFHTTPClient *manager = [[AFHTTPClient alloc] initWithBaseURL:URL]; | |
[manager GET:@"/messages" parameters:nil success:^(NSHTTPURLResponse *response, id responseObject) { | |
[resources addObjectsFromArray:responseObject[@"resources"]]; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation Singleton | |
static id _sharedManager; | |
+ (instancetype)sharedManager | |
{ | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
_sharedManager = [[self alloc] init]; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . -type f -print | xargs grep "some test ..." |
OlderNewer