This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
see discussion below |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% @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]). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
class Parser | |
def parse(string) | |
stack = [] | |
tokens = string.split(' ') | |
tokens.each do |token| | |
if token =~ /\d/ | |
value = token.to_i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import sys | |
for p in json.load(sys.stdin): | |
if p['head']['ref'] == sys.argv[1]: | |
print p['html_url'] |
OlderNewer