Skip to content

Instantly share code, notes, and snippets.

View parthjdabhi's full-sized avatar
🎯
Focusing

Parth Dabhi parthjdabhi

🎯
Focusing
View GitHub Profile
@parthjdabhi
parthjdabhi / README.md
Created March 30, 2023 04:58 — forked from Mike-Gough/README.md
Setup new React Native project with Typescript and Storyboard

React Native App Creation Recipe

This is a step-by-step guide to create React Native app.

You will get an application which has;

  • TypeScript
  • Linting
  • Formatting
  • Testing
@parthjdabhi
parthjdabhi / concurrency.swift
Created July 3, 2017 09:06 — forked from werediver/concurrency.swift
Limiting concurrent tasks.
import Foundation
func dispatch_async_batch(tasks: [() -> ()], limit: Int, completion: (() -> ())?) {
if tasks.count > 0 || completion != nil {
let q = dispatch_queue_create("dispatch_async_batch", DISPATCH_QUEUE_CONCURRENT);
let sema = dispatch_semaphore_create(limit);
dispatch_async(q, {
for task in tasks {
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER)
@parthjdabhi
parthjdabhi / FatalError+Ext.swift
Created July 3, 2017 09:05 — forked from werediver/FatalError+Ext.swift
Better `fatalError()`.
import Foundation
func fatalError<T>(@autoclosure message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> T {
fatalError(message(), file: file, line: line)
}
// Demo
protocol ResultType {
@parthjdabhi
parthjdabhi / Api.swift
Created January 2, 2017 08:35 — forked from seyhunak/Api.swift
Swift - JSON API
class API {
let uri = "https://api.com/endpoint" // replace your api endpoint (json)
func getData(completionHandler: ((NSArray!, NSError!) -> Void)!) -> Void {
let url: NSURL = NSURL(string: uri)!
let ses = NSURLSession.sharedSession()
let task = ses.dataTaskWithURL(url, completionHandler: {data, response, error -> Void in
@parthjdabhi
parthjdabhi / main.js
Created January 2, 2017 08:34 — forked from seyhunak/main.js
Targeted Push Notifications: Parse.com Cloud Code
// Use Parse.Cloud.define to define as many cloud functions as you want.
// For example:
Parse.Cloud.define("hello", function (request, response) {
response.success("Hello world!");
});
Parse.Cloud.define("userWithEmailExists", function (request, response) {
var email = request.params.email;
if (email != null && email !== "") {
email = email.trim();
class Brew {
var temp: Float = 0.0
}
class BrewViewModel : NSObject {
var brew = Brew()
dynamic var temp: Float = 0.0 {
didSet {
self.brew.temp = temp
}
@parthjdabhi
parthjdabhi / drive.py
Created October 4, 2016 18:26 — forked from basuke/drive.py
Create the GPX file from origin and destination using the GoogleMap Direction API. You can use this output for simulate the location apps in Xcode.
#
# python drive.py "origin" ["waypoint" ... ] "destination"
#
# i.e. python drive.py "Union Square, San Francisco" "Ferry Building, San Francisco" 'Bay Bridge' SFO
import sys, json, urllib2, md5, os.path, pprint
from math import radians, sin, cos, atan2, pow, sqrt
from urllib import quote_plus
from xml.sax.saxutils import escape
from optparse import OptionParser
@parthjdabhi
parthjdabhi / introrx.md
Created April 27, 2016 06:52 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@parthjdabhi
parthjdabhi / gist:474da4f46ad84748d1b3
Last active August 29, 2015 14:26 — forked from andrewzimmer906/gist:3145581
Post Photo and Message wall with Facebook iOS6 SDK
// Start here https://developers.facebook.com/docs/getting-started/getting-started-with-the-ios-sdk/
// Install the Facebook SDK, get it linked up, create an app, and get that setup correctly
// in your info.plist, appDelegate, and build settings.
//Note: This example uses ARC. If you aren't using ARC, made sure to release/retain objects as needed.
//Now for the fun part.
////////////////////////////