Skip to content

Instantly share code, notes, and snippets.

Adam R. Smith sunetos

Block or report user

Report or block sunetos

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
sunetos / iterize.jl
Last active Aug 29, 2015
Julia macro to generate iterator versions of collection functions
View iterize.jl
using Devectorize
macro makeiter(func, name)
expr = quote
immutable $name{X}
Base.start(i::$name) = start(i.x)$name, s) = ((v, s) = next(i.x, s); ($func(v), s))
sunetos / duke-cc.js
Created Aug 2, 2014
Duke Chromecast Test
View duke-cc.js
Copyright (C) 2013 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
sunetos /
Last active May 27, 2017
A breakdown of my condensed, obfuscated fizzbuzz for educational purposes
#!/usr/bin/env python
__author__ = 'Adam R. Smith ('
# Loop from 0 through 99. Need zero-based for the later cyclic bit-shifting.
for x in xrange(100):
# There are 4 possible outputs on each iteration of the loop.
# 4 possibilities requires 2 bits to store (0, 1, 2, 3):
# 0 == 00b == the number (x + 1)
# 1 == 01b == 'Fizz' when a multiple of just 3
sunetos / update-julia
Created May 22, 2014
Update to latest Julia nightly on a Mac
View update-julia
echo "Downloading Julia v$VERSION nightly..."
curl -fsSL "$URL" > "$dmg"
sunetos / maybe.jl
Last active Aug 29, 2015
Julia macro for typed optional function arguments
View maybe.jl
# Mark a function argument of any type as optional by generating a Union.
# If a default value is not defined, it assumes "nothing".
# Examples:
# function(x::Int, @maybe y::MyType)
# function(x::Int, @maybe y::MyType=someval)
macro maybe(argexpr)
default = :nothing
if argexpr.head == :(=)
argexpr, default = argexpr.args
sunetos / udacity-video-expand.js
Last active Aug 29, 2015
Udacity Video Auto-Expand
View udacity-video-expand.js
// ==UserScript==
// @name Udacity Video Auto-Expand
// @namespace
// @version 1.0
// @description Make Udacity videos automatically fill the page. Handy with Chromecast/Airplay.
// @match
// @copyright 2014+,
// ==/UserScript==
var w = 1280,
sunetos /
Created Nov 4, 2012
Bitey Autogeneration of Struct Member Names with Ctags
#!/usr/bin/env python
"""Patch bitey to auto-generate struct member names with exuberant ctags."""
__author__ = ' (Adam R. Smith)'
from collections import OrderedDict
import logging as log
import os
import subprocess
sunetos / gist:1068329
Created Jul 6, 2011
Simple Python ID Allocation Pool
View gist:1068329
__author__ = 'Adam R. Smith'
class IDPool(object):
Create a pool of IDs to allow reuse. The "new_id" function generates the next
valid ID from the previous one. If not given, defaults to incrementing an integer.
def __init__(self, new_id=None):
if new_id is None: new_id = lambda x: x + 1
import redis
from contextlib import contextmanager
def redisLock(r, key):
Acquire a lock on a particular key (makes a new mutex key).
This is not meant for very high concurrency, just to avoid
data corruption in simple cases.
View hillclimb.js
* @preserve
* Javascript Hill Climb Algorithm.
* @author Adam R. Smith
* Licensed under the new BSD License:
You can’t perform that action at this time.