Skip to content

Instantly share code, notes, and snippets.

View piemonte's full-sized avatar

patrick piemonte piemonte

View GitHub Profile
@domhofmann
domhofmann / onono.md
Last active August 23, 2020 11:59
onono

Onavo Protect is a free and popular VPN owned by Facebook.

Facebook ostensibly uses Onavo to monitor user network traffic, specifically to gain insight into what is and isn't working in competing apps. That kind of sucks if you're building a consumer app and aren't planning on selling it to Facebook.

Detecting if the people who use your app are also using Onavo and encouraging them to disable it might be helpful to you.

Here is some Swift code that does that:

func checkForBadIP (_ ip: String) -> Bool {
@beesandbombs
beesandbombs / slicedCube.pde
Created April 30, 2018 20:52
sliced cube
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@reitzig
reitzig / Camelizer.swift
Created February 22, 2018 17:26
Convert Swift strings to camel case
fileprivate let badChars = CharacterSet.alphanumerics.inverted
extension String {
var uppercasingFirst: String {
return prefix(1).uppercased() + dropFirst()
}
var lowercasingFirst: String {
return prefix(1).lowercased() + dropFirst()
}
@piemonte
piemonte / NextLevelGLContext.swift
Created February 13, 2018 17:58
OpenGLES + SceneKit render context for planar frame buffers
//
// NextLevelGLContext.swift
// NextLevel
//
// Created by Patrick Piemonte on 9/26/16.
//
// The MIT License (MIT)
//
// Copyright (c) 2016-present patrick piemonte (http://patrickpiemonte.com/)
//
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@erica
erica / bangbang.md
Last active November 9, 2017 19:17

Introducing the !! "Unwrap or Die" operator to the Swift Standard Library

Introduction

This proposal introduces an annotated forced unwrapping operator to the Swift standard library, completing the ?, ??, and ! family with !!. The "unwrap or die" operator provides text feedback on failed unwraps, to support defensive programming. This operator is commonly implemented in the larger Swift Community and should be considered for official adoption.

@mminer
mminer / MyService.swift
Last active April 23, 2024 23:00
Components of XPC service.
import Foundation
class MyService: NSObject, MyServiceProtocol {
func upperCaseString(_ string: String, withReply reply: @escaping (String) -> Void) {
let response = string.uppercased()
reply(response)
}
}
@rootulp
rootulp / export_foursquare_checkins.py
Last active June 13, 2020 01:38 — forked from dlo/export_foursquare_checkins.py
Download all your Foursquare checkins with Python.
# Before running this script execut the following command:
# $ pip install requests
# To run this script execute:
# $ python export_foursquare_checkins.py
import requests
import json
url_template = 'https://api.foursquare.com/v2/users/self/checkins?limit=250&oauth_token={}&v=20131026&offset={}'
# If you navigate to https://developer.foursquare.com/docs/explore, Foursquare
// Evaluates the given closure when two `Optional` instances are not `nil`,
// passing the unwrapped values as parameters. (Thanks, Mike Ash, Tim Vermeulen)
// Following the example of IEEE754 with NAN, any comparison involving
// .None is false
//
// See also: http://stackoverflow.com/questions/1565164/what-is-the-rationale-for-all-comparisons-returning-false-for-ieee754-nan-values
// Brent RG has a really interesting take here: https://gist.github.com/brentdax/60460ad4578d5d8d52a9d736240cfea6
fileprivate func _flatMap2<T, U, V>(_ first: T?, _ second: U?, _ transform: (T, U) throws -> V?) rethrows -> V? {
@kennwhite
kennwhite / 1944_OSS_Simple_Sabotage_Field_Manual.md
Last active March 28, 2026 03:48
1944 OSS Simple Sabotage Field Manual