This file contains hidden or 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
ACAccountStore *accountStore = [[ACAccountStore alloc] init]; | |
ACAccountType *facebookAccountType = [accountStore accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook]; | |
id options = @{ | |
ACFacebookAppIdKey: @"403376439767549", | |
ACFacebookPermissionsKey: @[ @"email", @"read_friendlists"], | |
ACFacebookAudienceKey: ACFacebookAudienceFriends | |
}; | |
[accountStore requestAccessToAccountsWithType:facebookAccountType | |
options:options | |
completion:^(BOOL granted, NSError *error) { |
This file contains hidden or 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
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { | |
SLComposeViewController *rexPost = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; | |
[rexPost setInitialText:@"IOS Learning"]; | |
[rexPost addURL:[[NSURL alloc] initWithString:@"http://www.google.com"]]; | |
[self presentViewController:rexPost animated:YES completion: nil]; | |
[rexPost setCompletionHandler: ^(SLComposeViewControllerResult result){ | |
if (result == SLComposeViewControllerResultDone) { | |
NSLog(@"Post success"); | |
} | |
}]; |
This file contains hidden or 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
// In app.js line 148 | |
// defined a collection class | |
var Collection = Appify.Collection = function(protoProps) { ... } | |
// It has extended Event modules | |
// It listen add and remove model event | |
// user can do: add and remove | |
var products = new Appify.Collection(); | |
var product = new ProductModel({ name: "t-shirt"}) | |
products.add(product); // => length = 1 |
This file contains hidden or 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
<!-- Using handlebar.js syntax --> | |
<ul id="events"> | |
{{foreach event in events}} | |
<li> | |
<h3>{{event.name}}</h3> | |
<p>{{event.desc}}</p> | |
</li> | |
{{/foreach}} | |
</ul> |
This file contains hidden or 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
var routingTable = { | |
'/': function() { | |
redirect_to('products#index') | |
}, | |
'/products': function() { | |
action("products#index"); | |
}, | |
'/products/:id': function(id) { | |
action("products#show", id); | |
} |
This file contains hidden or 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
<!-- products template --> | |
<ul data-bind="products"> | |
<li>{{product.name}}</li> | |
</ul> | |
<!-- js --> | |
var products = Product.fetchAll() | |
product.add(new product({name: 'shoe'}) |
This file contains hidden or 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
import java.util.Random; | |
class Matrix { | |
public int[][] matrix; | |
public int m, n; | |
// Col, n | |
public Matrix(int m, int n) { | |
this.matrix = new int[m][n]; |
This file contains hidden or 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 './lzw.rb' | |
require './run_length.rb' | |
def source_gen(range) | |
range.map { ("A".."B").to_a[rand(2)] }.join | |
end | |
def entropy(code) | |
code.split('').group_by(&:upcase) | |
.collect { |key, val| [key, val.size.to_f / code.size] } |
This file contains hidden or 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
PREFIX = "source_" | |
POSTFIX = ".txt" | |
LENGTH = 64 | |
RANGE = 'A'..'H' | |
SIZE = RANGE.to_a.size - 1 | |
FILE_CODE = 'a'..'d' | |
def gen; 1.upto(LENGTH).map { RANGE.to_a[rand(SIZE)] }.join; end | |
# Save result to files |
This file contains hidden or 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
Employee *e1 = [[Employee alloc] init]; | |
e1.salary = @1000; | |
Employee *e2 = [[Employee alloc] init]; | |
e2.salary = @2000; | |
Employee *e3 = [[Employee alloc] init]; | |
e3.salary = @3000; | |
Employee *e4 = [[Employee alloc] init]; | |
e4.salary = @4000; | |
NSArray *employees = @[e1, e2, e3, e4]; |