Skip to content

Instantly share code, notes, and snippets.

View ivanfoong's full-sized avatar

ivanfoong ivanfoong

View GitHub Profile
type MyADT = {
t: "Case1";
v1: string;
} | {
t: "Case2";
v2: string;
at: number;
} | {
t: "Case3",
v2: string
@ivanfoong
ivanfoong / ExampleViewController.swift
Last active December 5, 2017 02:13
Generic wrapper for Observable values
class ViewModel {
var content: Observable<String?> = Observable(nil)
func seedContent() {
self.content.value = "Seeded content"
}
}
class ExampleViewController {
@IBOutlet weak var contentTextField: UITextField!
@adeekshith
adeekshith / .git-commit-template.txt
Last active September 19, 2025 10:32 — forked from Linell/.git-commit-template.txt
This commit message template helps you write great commit messages and enforce it across teams.
# <type>: (If applied, this commit will...) <subject> (Max 50 char)
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# Provide links or keys to any relevant tickets, articles or other resources
# Example: Github issue #23
@chirag04
chirag04 / Install.md
Last active March 29, 2019 03:49
compile rocksdb as backend for asyncstorage

Credits

All credit to @sahrens for sharing fb's internal implementation.

Setup

  • clone rocksdb from https://github.com/facebook/rocksdb.

  • edit MakeFile inside rocksdb. Search for Platform-specific compilation around line 1122. Make th next few lines to look like this:

ifeq ($(PLATFORM), IOS)
# For iOS, create universal object files to be used on both the simulator and
@giumas
giumas / Logging - SQLite handler
Last active February 15, 2023 02:23
A minimal SQLite handler for the python logging module
from __future__ import absolute_import, division, print_function, unicode_literals
import sqlite3
import logging
import time
__version__ = "0.1.0"
initial_sql = """CREATE TABLE IF NOT EXISTS log(
/*
Erica Sadun, http://ericasadun.com
GameplayKit Available 10.11, iOS 9
*/
import Foundation
import GameplayKit // only available on OS X 10.11, iOS 9
@Lvt
Lvt / WWDC 2015 Movie Downloader
Last active August 29, 2015 14:22
WWDC 2015 Movie Downloader
Execute in Terminal. This Downloads every Movie in HD
curl -s https://developer.apple.com/videos/wwdc/2015/ | grep "?id=" | sed "s/.*id\=/curl\ \-s https:\/\/developer\.apple\.com\/videos\/wwdc\/2015\/\\\?id\=/"\ | sed "s/\".*/\| grep HD \| sed \"s\/.*\<a href\\\\=\\\\\"\/\/\"\| sed \"s\/\\\\\".\*\/\/\" /" | sh | sed "s/http/curl \-C \- \-O \"http/" | sed "s/\?dl\=1/\"/" | grep http | sh
Not working any more
@alexsporn made the script better
@boopathi
boopathi / README.md
Last active September 25, 2025 20:45
Creating a Swift-ReactNative project

Settings

  1. Create a project in XCode with the default settings
    • iOS > Application > Single View Application
    • Language: Swift
  2. Under project General settings, add ReactKit to Linked Framework and Libraries
    • + > Add Other... and choose /path/to/react-native/ReactKit/ReactKit.xcodeproj
  3. Now ReactKit would have been imported. Link it by choosing it from the list.
    • + > lib.ReactKit.a
  4. Under project Build Settings,
@mjmsmith
mjmsmith / wwdc.rb
Created September 5, 2014 02:03
WWDC videos
require "date"
require "nokogiri"
require "open-uri"
builder = Nokogiri::XML::Builder.new do |xml|
xml.feed ({"xml:lang"=>"en-US", "xmlns"=>"http://www.w3.org/2005/Atom"}) {
xml.id "http://camazotz.com/wwdc.xml"
xml.link ({"rel"=>"self", "href"=>"http://camazotz.com/wwdc/index.xml"})
xml.link ({"rel"=>"alternate", "type"=>"text/html", "href"=>"https://developer.apple.com/videos/wwdc/"})
xml.title "WWDC Videos"
@mattt
mattt / regex.swift
Created August 11, 2014 18:08
Creating a regular expression object from a String literal
class Regex {
let pattern: String
let options: NSRegularExpressionOptions!
private var matcher: NSRegularExpression {
return NSRegularExpression(pattern: self.pattern, options: nil, error: nil)
}
required init(pattern: String, options: NSRegularExpressionOptions = nil) {
self.pattern = pattern