Skip to content

Instantly share code, notes, and snippets.

View Gurpartap's full-sized avatar
:octocat:
Working from home

Gurpartap Singh Gurpartap

:octocat:
Working from home
View GitHub Profile
@Gurpartap
Gurpartap / Podfile.rb
Last active December 11, 2015 09:26
gRPC issue #4350
source "https://github.com/CocoaPods/Specs.git"
platform :ios, "8.0"
use_frameworks!
inhibit_all_warnings!
pod "Protobuf", "~> 3.0.0-alpha-4.1"
pod "gRPC", git: "https://github.com/grpc/grpc"
pod "EchoSDK", path: "../proto"
{
"data": {
"id": 14830193,
"type": "twitter_connection",
"attributes": {
"created_at": "2015-09-15T11:19:50.201187+05:30",
"updated_at": "2015-09-15T11:19:50.201187+05:30",
"screen_name": "Gurpartap"
}
}
@Gurpartap
Gurpartap / Godfather_.swift
Last active September 15, 2015 07:48 — forked from ivangodfather/gist:9f3ad527198ee513308e
For @Godfather_ on IRC
request(.GET, CUSTOMER_URL, parameters: params, encoding: .URL).responseJSON { (request, response, result) -> Void in
if let message = JSON(result.value ?? "")["message"].string ?? "Default value to make it nonOptional" {
switch(result) {
case .Success(let json):
if let customer = JSON(json)["customer"].dictionaryObject {
GlobalCache.sharedInstance.setCustomer(customer)
}
completion(succeed: response?.statusCode == 200, message: message)
case .Failure(_,_):
completion(succeed: false, message: message)
@Gurpartap
Gurpartap / items-for-sale.md
Last active September 17, 2015 07:13
Items for sale

Available:

  • Sony alpha NEX-5 14.2 MP Mirrorless Camera - Black — Kit w/ 16mm & 18-55mm Lenses, flash and spare battery (excellent working condition with some wear and tear)
  • PlayStation 3 God of War 3 Edition w/ GoW 3, Portal 2 and Red Dead Redemption (mint condition, only played RDR)
  • PSP (PlayStation Portable) — Silver w/ Hard casing, spare battery and games (Family Guy, God of War, Exterminator, etc.) (mint condition)
  • Creative Computer Speakers (basic speakers, never used)
  • Philips Computer Speakers (basic speakers, never used)
  • AudioEngine 5 Speakers w/ built-in amp (Studio Monitors) (needs repair for pops and crackles - common problem in this model)
  • 2007 PC w/ Q6600 2.4GHz, Asus P5K Deluxe Motherboard, AMD ATI 4800 512MB Graphics Card, 2GB GSkill RAM (needs repair; motherboard not posting - known problem with this MB model)
  • 2008 MacBook Pro 2.6GHz w/ spare MagSafe charger (needs new battery, keyboard up/down keys not responding)
@Gurpartap
Gurpartap / protocols.go
Last active August 29, 2015 14:27
Golang type interface implementation (protocol of Swift)
package main
import "fmt"
// protocol
type Specimen interface {
NumLegs() int
}
var Species = []Specimen{}
@Gurpartap
Gurpartap / select.playground
Created February 16, 2015 20:52
"select" non-nil elements.
// "select" non-nil elements.
var data: Array<String> = ["0", "a"]
var wrappedIntsWithOptionals = data.map { $0.toInt() } as Array<Int?>
println("wrappedIntsWithOptionals: \(wrappedIntsWithOptionals)")
// wrappedIntsWithOptionals: [Optional(0), nil]
// ## This works
@Gurpartap
Gurpartap / gist:557660f1f3d09cbf420e
Created February 13, 2015 05:15
Swift STTwitter Reverse Auth Implementation
let TWITTER_CONSUMER_KEY = ""
let TWITTER_CONSUMER_SECRET_KEY = ""
let twitter = STTwitterAPI(OAuthConsumerKey: TWITTER_CONSUMER_KEY, consumerSecret: TWITTER_CONSUMER_SECRET_KEY)
// Step 1
twitter.postReverseOAuthTokenRequest({ (authenticationHeader) -> Void in
println("authenticationHeader: \(authenticationHeader)")
let twitterAPIOS = STTwitterAPI.twitterAPIOSWithFirstAccount() // Set your ACAccount instance here.
@Gurpartap
Gurpartap / LibrarySpec.swift
Last active August 29, 2015 14:14
Quick bug? Update: Not anymore.
import Quick
import Nimble
class LibrarySpec: QuickSpec {
override func spec() {
describe("library") {
var library: Library!
beforeEach {
library = Library()
@Gurpartap
Gurpartap / PlayerViewController.swift
Last active January 8, 2016 15:47
FreeStreamer meta data example in Swift (stripped out of shipped code)
import Foundation
import AVFoundation
// My app doesn't use meta data, so you're on your own with the following code.
public class PlayerViewController: UIViewController, FSPCMAudioStreamDelegate {
private var _cachedAudioController: FSAudioController?
private var _audioController: FSAudioController! {
get {