Skip to content

Instantly share code, notes, and snippets.

View tikipatel's full-sized avatar

Pratikbhai Patel tikipatel

  • San Francisco, CA
View GitHub Profile
@selimslab
selimslab / get_gists.py
Last active December 23, 2023 15:52 — forked from leoloobeek/get_gists.py
Download all gists of a user
import sys
from subprocess import call
import json
import os
import requests
def download_gists(gists: list):
for gist in gists:
call(["git", "clone", gist["git_pull_url"]])
## Install perf in docker container
### ubuntu 18.4
### kernel 4.14.173-137.229.amzn2.x86_64
docker exec -it {containerid} sh
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.14.173.tar.xz && tar -xf ./linux-4.14.173.tar.xz && cd linux-4.14.173/tools/perf/ && apt -y install flex bison && make -C . && make install
./perf
./perf list
./perf bench mem all
@lattner
lattner / TaskConcurrencyManifesto.md
Last active May 7, 2024 09:05
Swift Concurrency Manifesto
@lattner
lattner / async_swift_proposal.md
Last active April 21, 2024 09:43 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@leoloobeek
leoloobeek / get_gists.py
Created April 26, 2017 21:34
Download all gists for a specific user
# first: mkdir user && cd user && cp /path/to/get_gists.py .
# python3 get_gists.py user
import requests
import sys
from subprocess import call
user = sys.argv[1]
r = requests.get('https://api.github.com/users/{0}/gists'.format(user))
@NSExceptional
NSExceptional / ResponseParser.swift
Last active February 21, 2018 22:55
A simple class to automate the parsing of an NSURLSessionTask response.
//
// Copyright © 2016 Tanner Bennett. All rights reserved.
//
import Foundation
typealias ResponseParserBlock = (ResponseParser) -> Void
class ResponseParser {
@CTMacUser
CTMacUser / Lucky Numbers.swift
Last active April 3, 2022 20:18
Using Swift to demonstrate the Sieve of Eratosthenes
import Foundation
/**
Run an incremental counter, but return only the values that survive the "lucky number" process.
The process is to list all the positive integers, then filter out entries in stages. For all the numbers in a stage, let *N* be the first unfiltered number that is neither 1 nor been already been used as a filter seed for a previous stage, and filter out every Nth number. The first pass uses 2 and therefore filters out every second number, i.e. the even numbers. The second pass uses 3 and therefore filters out every third number that survived the 2-stage. The third pass uses 7 and therefore filters out every seventh number that survived both the 2- and 3-stages. The fourth pass uses 9 and therefore filters out every ninth number that survived the 2-, 3-, and 7-stages. (Note that 2 is the only seed that eliminates itself in its filter. Some definitions of lucky numbers avoid this irregularity by starting with the odd positive integers.)
*/
public struct LuckyNumberGenerator<C
// Would you rather use this:
NSLayoutConstraint(item: label, attribute: .Leading, relatedBy: .Equal, toItem: button, attribute: .Trailing, multiplier: 1, constant: 0).active = true
// or this?
label.constrain(.Leading, .Equal, to: button, .Trailing, plus: 20)
@mackuba
mackuba / wwdc15.md
Last active August 6, 2022 17:28
New stuff from WWDC 2015

Here's my own list of the interesting stuff announced during this year's WWDC, collected from the keynotes, various Apple docs, blog posts and tweets.

If you're planning to watch the videos, I really recommend this Mac app that helps you download and watch them: https://github.com/insidegui/WWDC.

OS X El Capitan

http://www.apple.com/osx/elcapitan-preview/

  • split view - two apps side by side on full screen
@erikreagan
erikreagan / mac-apps.md
Created August 4, 2012 19:18
Mac developer must-haves

Mac web developer apps

This gist's comment stream is a collection of webdev apps for OS X. Feel free to add links to apps you like, just make sure you add some context to what it does — either from the creator's website or your own thoughts.

— Erik