Skip to content

Instantly share code, notes, and snippets.

🦊
puppies

Greg Heo gregheo

🦊
puppies
View GitHub Profile
@gregheo
gregheo / url components.swift
Created Feb 7, 2018
Fake URL + url encoded query paramaters
View url components.swift
import Foundation
let encodedString = "data=%7B%0D%0A%22coffee%22%3A%20%22coffee%22%2C%0D%0A%22beer%22%3A%20%22beer%22%2C%0D%0A%22has_bylaws%22%3A%20true%0D%0A%7D%0D%0A"
guard let c = URLComponents(string: "http://fake.com/?" + encodedString) else {
fatalError("could not generate url components! :(")
}
for item in c.queryItems ?? [] {
print("Got key \(item.name) with value \(item.value)")
@gregheo
gregheo / objc-dispatch-demo.swift
Created Dec 5, 2017
Swift Unboxed: @objc and dynamic dispatch
View objc-dispatch-demo.swift
/*
@objc and dynamic dispatch demo
From the article "@objc, Swift, and the Depths of Dynamic Dispatch"
https://swiftunboxed.com/interop/objc-dynamic/
*/
import Foundation
class ToObjcOrNotObjc {
@discardableResult
View remainder.c
#include <stdio.h>
#include <math.h>
int main(void) {
double const number = 8.0;
for (double i = number; i < number * 2 + 1; ++i) {
printf("remainder(%2.0f, %2.0f) = %2.0f\n", i, number, remainder(i, number));
}
View keybase.md

Keybase proof

I hereby claim:

  • I am gregheo on github.
  • I am gregheo (https://keybase.io/gregheo) on keybase.
  • I have a public key whose fingerprint is 1A52 D760 6FDD D32E 2B2A D269 F17C 8DA5 8AFF CE57

To claim this, I am signing this object:

View gist:160c40993be9274390ce
import UIKit
import CoreImage
class CustomFilter : CIFilter {
var privateInputImage: CIImage?
var inputImage: CIImage? {
set {
privateInputImage = newValue
}
get {
@gregheo
gregheo / gist:4122880
Created Nov 21, 2012
FB upload example
View gist:4122880
-(void) uploadVideo {
NSMutableDictionary *fbParams = @{@"title": @"Video Title",
@"description": @"Video Description",
@"json", @"format"};
FBVideoUpload *faceBookVideoUpload = [[FBVideoUpload alloc] init];
faceBookVideoUpload.apiKey = APP_KEY;
faceBookVideoUpload.appSecret = APP_SECRET;
faceBookVideoUpload.accessToken = accessToken;
[faceBookVideoUpload startUploadWithURL:videoURL fbParams delegate:self];
You can’t perform that action at this time.