Skip to content

Instantly share code, notes, and snippets.

-(void) searchForPlaces {
ACAccountStore *store = [[ACAccountStore alloc] init];
ACAccountType *type = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
NSArray *permissions = @[@"email"];
NSDictionary *options = @{ ACFacebookAppIdKey : @"229934313842253", ACFacebookPermissionsKey : permissions, ACFacebookAudienceKey : ACFacebookAudienceOnlyMe };
[store requestAccessToAccountsWithType:type options:options completion:^(BOOL granted, NSError *error) {
NSArray *accounts = [store accountsWithAccountType:type];
@mattshapiro
mattshapiro / gist:e148000d977559d88dd2
Created September 9, 2015 22:03
Stupid, simple, Android view dragging
public class SelectionHandleListener implements View.OnTouchListener {
float x, y;
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
float rx = motionEvent.getRawX();
float ry = motionEvent.getRawY();
switch(motionEvent.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_POINTER_DOWN:
x = rx;
@mattshapiro
mattshapiro / gist:f1d6ac095aac995d6e74
Created September 15, 2015 04:49
If you ever need to randomly generate fake "words" using english alphanumerics in Java...
private String getRandomizedWords(int word_count) {
String contentAsString = "";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while(word_count-- > 0) {
// generate word
int wordLength = Math.abs((rnd.nextInt() % MAX_WORD_LENGTH) + 1);
for(int i = 0; i < wordLength; i++) {
int val = Math.abs((rnd.nextInt() % 62) + 1);
char nextChar = ' ';
if (val >= 0 && val <= 9) {
@mattshapiro
mattshapiro / gist:5e812ad45ca561253996
Created February 18, 2016 01:04
Unity 5 Accelerometer-based game object rotation
float x = -Input.acceleration.x * 180;
float y = Input.acceleration.y * 180;
x = limit (x, MAX_ANGLE);
y = limit (y, MAX_ANGLE);
Quaternion quato = Quaternion.Euler(y, 0, x);
rb.transform.rotation = Quaternion.Lerp(rb.transform.rotation, quato, Time.deltaTime * 5.0f);