Skip to content

Instantly share code, notes, and snippets.

View aerosol's full-sized avatar
🌞
Praise the sun

hq1 aerosol

🌞
Praise the sun
View GitHub Profile
@aerosol
aerosol / t.py
Created May 14, 2014 19:25 — forked from AeroNotix/t.py
def random_device(reuse_owner=False, **kwds):
def wrapper(f):
def wrapped(self):
if reuse_owner and hasattr(self, 'device'):
print "Reusing owner %s" % self.device
d = self.device
else:
print "no owner"
d = 'A NEW DEVICE'
self.device = d

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

-module(gen_ale_drinker).
%% There are 2 types of drink:
-type style() :: ale | not_ale.
%% Need to support imperial measurements (not US pints though)
-type volume() :: {imperial_pint, non_neg_integer()} | {litre, non_neg_integer()}.
-type beverage() :: {style(), volume()}.
-callback drink(beverage()) -> ok | {error, ebeeroverflow}. %% This should never happen
# Copyright 2012 Erlware, LLC. All Rights Reserved.
#
# This file is provided to you 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
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
@aerosol
aerosol / foo.erl
Created December 17, 2012 12:58 — forked from anonymous/foo.erl
{module, foo}. %% version = 0
{exports, [{bar,1},{module_info,0},{module_info,1}]}.
{attributes, []}.
{labels, 7}.
{function, bar, 1, 2}.
@aerosol
aerosol / gist:1293679
Created October 17, 2011 20:20
Dynamic compilation
validate_rules() ->
?SYS_INFO("Validating common rules configuration..."),
case compile:file(?PRIV("common_rules.erl"), [strong_validation, report, return, {i, ?PRIV("../include")}]) of
{ok, _, _} ->
?SYS_DEBUG("File common_rules.erl validated successfully"),
ok;
{ok, _, _, Warnings} ->
ok;
{ok, _, _, Warnings} ->
case Warnings of