Skip to content

Instantly share code, notes, and snippets.

View azinman's full-sized avatar

Aaron Zinman azinman

  • San Francisco
View GitHub Profile
@azinman
azinman / unmonkeypatch.py
Created October 5, 2016 21:41
Enable PTVSD remote debugging despite gevent monkey patching
# Somewhere in our Django stack gevent was being invoked and monkey patching socket and threads.
# PTVSD uses low-level sockets + a thread to work, and the monkey patched version (even if you
# call gevent.monkey.patch_all()) somehow was not working correctly.
# By reloading those modules, you can get the debugger to work correct and step through your code.
import ptvsd, socket, thread, threading
reload(socket)
reload(thread)
reload(threading)
ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))
ptvsd.wait_for_attach()
@azinman
azinman / JsonCastingAnnoyances.swift
Last active April 25, 2016 19:37
Some non-obvious behavior casting values
var outputTarget = 8
// AnyObject forces the Swift Int to become an NSNumber. NSNumbers can cast
// to various primitive types even if the original value is not of the same
// type. For example, ints can be cast to bool (objective-c bools are
// actually 8-bit chars), and the bool is true if the value is non-zero (can
// be 8, -100, etc).
func get(key: String) -> AnyObject? {
return outputTarget
}
@azinman
azinman / NamingPackage.swift
Created March 25, 2016 01:56
autogenerated swift files from VDL
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Source: v.io/v23/naming
public enum Naming {
/* The following constants originate in file: types.vdl */
@azinman
azinman / reflectionLimitations.swift
Created February 25, 2016 03:06
swift limitations for reflection
enum X : Int {
case Foo = 2
case Bar = 8
case Baz = 4
}
// Can also do this with no difference
// enum X {
// case Foo
// case Bar
@azinman
azinman / jail.sb
Created February 25, 2016 02:56
Example jail for vanadium jenkins tests
(version 1)
(deny default)
(allow network*)
(allow file-write* file-read-data file-read-metadata
(regex "^/Users/zinman/vanadium")
(regex "^(/private)?/tmp"))
(allow file-read-data file-read-metadata
(regex "^/dev/autofs.*")
@azinman
azinman / AppDelegate.m
Last active February 20, 2018 06:53
@synchronized vs pthread mutex vs NSRecursiveLock vs Semaphore
//
// AppDelegate.m
// LockTest
//
// Created by zinman on 1/29/16.
//
#import "AppDelegate.h"
#import <pthread.h>
### Keybase proof
I hereby claim:
* I am azinman on github.
* I am azinman (https://keybase.io/azinman) on keybase.
* I have a public key whose fingerprint is 648F C16E 7315 35E6 48FE C55A FA5C 5707 A23C 3CC7
To claim this, I am signing this object:
@azinman
azinman / gist:6479896
Created September 7, 2013 22:19
Convert a unix epoch into something human readable
$ date -d @1378585039
Sat Sep 7 20:17:19 UTC 2013
@azinman
azinman / floatDoubleTest.m
Created February 22, 2012 01:17
Comparison of float and double pre-defined values in iOS/LLVM
//
// main.m
// quicky
//
// Created by Aaron Zinman on 2/21/12.
// Copyright (c) 2012 Empirical Design LLC. All rights reserved.
//
#import <Foundation/Foundation.h>
@azinman
azinman / animation.js
Created June 3, 2011 05:38
Apply CSS transformations, remembering the past history. Useful for undoable animations/transitions.
// Undo-able CSS transformations on DOM objects
// Requires jQuery
// MIT Licensed
// Author: Aaron Zinman <aaron@azinman.com>
// Part of Defuse: http://defuse.media.mit.edu
// Tested in Safari, soon testing in: Chrome and Firefox
if (window.defuse == null) defuse = {animation:{}};
/**
* Applies a series of CSS transformation (contained in the cssObj dictionary)