Skip to content

Instantly share code, notes, and snippets.

View jonfriskics's full-sized avatar

Jon Friskics jonfriskics

View GitHub Profile
@jonfriskics
jonfriskics / AVRAnimatedTableViewCell.h
Last active August 29, 2015 14:00
Animations that persist in cells (sort of)
//
// AVRAnimatedTableViewController.m
// AnimationIssues
//
// Created by Adam Weeks on 5/2/14.
// Copyright (c) 2014 AppsVersusRobots, LLC. All rights reserved.
//
#import "AVRAnimatedTableViewController.h"
#import "AVRAnimatedTableViewCell.h"
func anyCommonElements <T, U where T: Sequence, U: Sequence, T.GeneratorType.Element: Equatable, T.GeneratorType.Element == U.GeneratorType.Element> (lhs: T, rhs: U) -> Bool {
for lhsItem in lhs {
for rhsItem in rhs {
if lhsItem == rhsItem {
return true
}
}
}
return false
}
extension CLLocationCoordinate2D: Equatable {}
extension Double {
func places(p: Double) -> String {
return NSString(format: "%\(p)f", self)
}
}
public func ==(lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool {
return lhs.latitude.places(3) == rhs.latitude.places(3) && lhs.longitude.places(3) == rhs.longitude.places(3)
@jonfriskics
jonfriskics / fb-messenger-ios-permissions.md
Last active November 23, 2015 11:30
Facebook Messenger Permissions and iOS

This document is an attempt to debunk all of those "Facebook Messenger is evil!" messages that are cluttering up my news feed. There's several versions of it, but this document is using this one for separating each claim: http://threepercenternation.com/2014/08/facebook-crosses-the-line-with-messenger-app/

Please let me know if I missed something or got something wrong - and if you're interested in working on an Android/Windows Phone version of this then that would be swell too!

Phone Calls and SMS Messages

Call phone numbers and send SMS messages – This means that if Facebook wants to…it can send text messages to your contacts on your behalf.

Developers can create a link that contains a phone number (tel:// URL Scheme), but the user will always be prompted with a "Call" action button - no phone call can automatically be triggered.

@jonfriskics
jonfriskics / gist:4706b45a712c0634815b
Created August 28, 2014 17:20
Stylish GitHub rules
// add these for https://github.com and http://github.com with Stylish (https://chrome.google.com/webstore/detail/stylish/fjnbnpbmkenffdnngjfgmeleoegfcffe?hl=en)
// fixes the sidebar repo list truncation on the /dashboard page
.css-truncate-target {
overflow: hidden !important;
white-space: normal !important;
display: block;
max-width: 500px !important;
}
#import "CSTableViewController.h"
@interface CSTableViewController ()
@end
@implementation CSTableViewController
- (id)initWithStyle:(UITableViewStyle)style
{
@jonfriskics
jonfriskics / functions.playground
Last active August 29, 2015 14:06
Function Argument Unwrap Optional
func myFunc1(name: String!) {
println(name); // playground shows "Jon1" is printed
}
func myFunc2(name: String) {
println(name); // playground shows "Jon2" is printed
}
let str1:String? = "Jon1"; // playground shows str1 is {Some "Jon1"}
let str2:String = "Jon2"; // playground shows str2 is "Jon2"
@jonfriskics
jonfriskics / AppDelegate.swift
Created September 29, 2014 20:11
Is there something special that I have to do when unwrapping objects and getting access to the structs inside of them? This currently works with forced unwrapping, but not with optional binding/chaining. Check out lines 74 through 78 in ViewController.swift
//
// AppDelegate.swift
// Test
//
// Created by Jon Friskics on 9/29/14.
// Copyright (c) 2014 Code School. All rights reserved.
//
import UIKit
@jonfriskics
jonfriskics / ComicViewController.swift
Last active August 29, 2015 14:07
Weird initializer behavior
import UIKit
class ComicViewController: UIViewController, UIScrollViewDelegate {
var comicToLoad:NSDictionary
/* This is a custom initializer, but it has to call init(nibName, bundle) or there's a compiler error.
I get that, because init(nibName, bundle) is the designated initializer, but ... */
init(passedInComic: NSDictionary) {
comicToLoad = passedInComic
Here's the code I'm using with some logs below.
- (void)viewWillAppear:(BOOL)animated
{
self.manager = [[CMMotionManager alloc] init];
self.manager.deviceMotionUpdateInterval = 0.2;
self.manager.accelerometerUpdateInterval = 0.2;
self.manager.gyroUpdateInterval = 0.2;
self.manager.magnetometerUpdateInterval = 0.2;
[self.manager startDeviceMotionUpdatesToQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *motion, NSError *error) {