Skip to content

Instantly share code, notes, and snippets.

@degan
degan / gist:70e8059507d173751294
Last active August 29, 2015 14:16
FREAK Attack server test
see discussion below
@jbenet
jbenet / NSTimeZone+AskGeo.h
Created April 7, 2011 11:27
Objective-C AskGeo API
// The MIT License
//
// Copyright (c) 2010 Juan Batiz-Benet
//
// 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:
@pamelafox
pamelafox / usermodel.py
Created July 6, 2011 21:08
SimpleGeo Timezone Calculation on Python App Engine
class User(db.Model):
location = db.StringProperty()
timezone = db.StringProperty(default='America/Los_Angeles')
# Do this once per user
def calculate_timezone(self):
from simplegeo import Client
client = Client('oauth key', 'oauth secret SHH')
response = client.context.get_context_by_address(self.location)
for feature in response['features']:
@klovadis
klovadis / gist:2548942
Created April 29, 2012 09:22
Typical node.js callback pattern
// include the filesystem module
var fs = require('fs');
// fs.readFile: read a file and all its contents,
// then call a callback function
fs.readFile('/some/file', function (err, contents) {
// if any error occurred, throw it
if (err) throw err;
@klovadis
klovadis / gist:2549029
Created April 29, 2012 09:35
Short circuit function chains if an error occurs
var fs = require('fs');
// read a file
function read_the_file(filename, callback) {
// begin by reading a file
fs.readFile(filename, function (err, contents) {
// an error occurred, i.e. the file was not found.
// instead of throwing an error, skip the other
@willf
willf / bitset.go
Created May 11, 2011 01:47
First implementation of bitsets
// Copyright 2011 Will Fitzgerald. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
/*
Package bitset implements bitsets.
It provides methods for making a bitset of an arbitrary
upper limit, setting and testing bit locations, and clearing
bit locations as well as the entire set.
@d11wtq
d11wtq / calc.erl
Last active December 15, 2015 07:08
Reverse Polish Notation Calculator in Erlang
%% @doc Reverse Polish Notation Calculator.
%%
%% Parses expressions like "1 2 3 + -" = -4
%%
%% This is an exercise in Learn You some Erlang for Great Good,
%% however I didn't read the text and just implemented it.
%%
%% I guess understanding stack-based parsing helps here.
-module(calc).
-export([rpn/1]).
@turboladen
turboladen / libav.rb
Last active December 17, 2015 08:28 — forked from jamiehodge/libav.rb
require 'formula'
class Libav < Formula
homepage 'http://libav.org/'
url 'http://libav.org/releases/libav-9.6.tar.xz'
sha1 '7c66e9776e83b13910eae960d63b7b86ad229dfe'
head 'git://git.libav.org/libav.git'
option "without-x264", "Disable H264 encoder"
@jakeonrails
jakeonrails / parser_spec.rb
Created January 25, 2014 00:38
Reverse Polish Notation parser
require 'spec_helper'
class Parser
def parse(string)
stack = []
tokens = string.split(' ')
tokens.each do |token|
if token =~ /\d/
value = token.to_i
@exupero
exupero / whichpull.py
Last active January 13, 2016 16:25
Getting the pull request for a branch with Python and Jq.
import json
import sys
for p in json.load(sys.stdin):
if p['head']['ref'] == sys.argv[1]:
print p['html_url']