Skip to content

Instantly share code, notes, and snippets.

View saniul's full-sized avatar

saniul saniul

View GitHub Profile
@saniul
saniul / brew-sync.sh
Created March 30, 2018 21:12 — forked from jamiew/brew-sync.sh
Sync Homebrew installations between Macs via Dropbox (including casks)
#!/bin/bash
# Sync Homebrew installations between Macs via Dropbox
#
BREW="/usr/local/bin/brew"
# first get local settings
echo "Reading local settings ..."
rm -f /tmp/brew-sync.*
@saniul
saniul / cmykKnot.pde
Created June 16, 2017 11:23 — forked from beesandbombs/cmykKnot.pde
cmyk knot
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);
@saniul
saniul / CustomInspectorCreator.cs
Created April 18, 2017 13:47 — forked from LotteMakesStuff/CustomInspectorCreator.cs
Editor extension that adds a tool to automagically generate boilerplate custom inspector code~ YES! Just drop it into a folder called 'Editor' and it adds a 'custom inspector' option into the Project window!
using UnityEngine;
using UnityEditor;
using System.IO;
public static class CustomInspectorCreator
{
[MenuItem("Assets/Create/Custom Inspector", priority = 81)]
static void CreateInsptorEditorClass()
{
foreach (var script in Selection.objects)
let testArray = ["zero", "one", "two"]
let reversedArray = testArray.reversed()
let oneIndex = ReversedRandomAccessIndex<[String]>(1)
let elementAtOne = reversedArray[oneIndex] // "zero"
let zeroIndex = ReversedRandomAccessIndex<[String]>(0)
// let elementAtZero = reversedArray[zeroIndex] // exception
@saniul
saniul / SimpleGeo.cs
Created September 18, 2016 00:47 — forked from phosphoer/SimpleGeo.cs
Simple Geometry Painter for Unity
// The MIT License (MIT)
// Copyright (c) 2016 David Evans @phosphoer
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
@saniul
saniul / NSDateComponentsFormatterWeirdness.playground
Created December 8, 2015 21:14
NSDateComponentsFormatter Weirdness
//: Playground - noun: a place where people can play
import Foundation
let formatter = NSDateComponentsFormatter()
formatter.unitsStyle = .Abbreviated
formatter.maximumUnitCount = 1
formatter.allowsFractionalUnits = true
var allowedUnits: NSCalendarUnit = [
.Year,

Things that programmers don't know but should

(A book that I might eventually write!)

Gary Bernhardt

I imagine each of these chapters being about 2,000 words, making the whole book about the size of a small novel. For comparison, articles in large papers like the New York Times average about 1,200 words. Each topic gets whatever level of detail I can fit into that space. For simple topics, that's a lot of space: I can probably walk through a very basic, but working, implementation of the IP protocol.

@saniul
saniul / 1. InputAlignment APIs
Created March 26, 2015 03:03
MacOSX10.10 Private Force Touch APIs
// I think this is the stuff that is responsible for the "bumpy pixels" behavior of the Force Touch trackpad in iMovie
//
// Generated by class-dump 3.5 (64 bit).
//
// class-dump is Copyright (C) 1997-1998, 2000-2001, 2004-2013 by Steve Nygard.
//
#pragma mark Function Pointers and Blocks
@saniul
saniul / gist:9f467d51859533006fd8
Created February 12, 2015 21:45
Apple Testflight User Export Bookmarklet
javascript: (function(){var t={eval:'"(function(){var t=artoo.scrape(\\".table-testers tbody tr\\",{name:function(t){return t(this).find(\\".tt-name span:first\\").text().trim()},email:function(t){return t(this).find(\\".tt-email span:first\\").text().trim()},status:function(t){return t(this).find(\\".tt-status span:first\\").text().trim()},latestBuild:function(t){return t(this).find(\\".tt-latest-build span:first\\").text().trim()}});artoo.saveCsv(t)}).call(this,artoo.$);"'},e=!0;if("object"==typeof this.artoo&&(artoo.settings.reload||(artoo.log.verbose("artoo already exists within this page. No need to inject him again."),artoo.loadSettings(t),artoo.hooks.trigger("exec"),e=!1)),e){var i=document.getElementsByTagName("body")[0];i||(i=document.createElement("body"),document.firstChild.appendChild(i));var a=document.createElement("script");console.log("artoo.js is loading..."),a.src="//medialab.github.io/artoo/public/dist/artoo-latest.min.js",a.type="text/javascript",a.id="artoo_injected_script",a.setAttribute
//
// MultiDirectionAdjudicatingScrollView.swift
// Khan Academy
//
// Created by Andy Matuschak on 12/16/14.
// Copyright (c) 2014 Khan Academy. All rights reserved.
//
import UIKit
import UIKit.UIGestureRecognizerSubclass