This file contains hidden or 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
#!/usr/bin/env python | |
# encoding: utf-8 | |
""" | |
Example of friendships computing for mapreduce | |
inspired by this post : http://stevekrenzel.com/finding-friends-with-mapreduce | |
""" | |
__author__ = "Tim Bart" | |
__copyright__ = "No copyright" |
This file contains hidden or 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
# saved from http://github.com/jhsu/ubstatus/blob/master/main.rb for reference | |
require 'sinatra' | |
require 'sinatra/activerecord' | |
require 'net/http' | |
require 'haml' | |
require 'lib/models/site.rb' | |
require 'lib/models/user.rb' | |
configure do |
This file contains hidden or 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 'rubygems' | |
require 'sinatra' | |
enable :sessions | |
get '/' do | |
session["value"] ||= "Hello world!" | |
"The cookie you've created contains the value: #{session["value"]}" | |
end |
This file contains hidden or 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
# Depends on the OS X "say" command | |
import time, datetime, subprocess, math, sys | |
def say(s): | |
subprocess.call(['say', str(s)]) | |
def seconds_until(dt): | |
return time.mktime(dt.timetuple()) - time.time() |
This file contains hidden or 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
if (!navigator.geolocation) { | |
navigator.geolocation = (function (window) { | |
function getCurrentPosition(callback) { | |
// NOTE: for some reason, chaging the url is *allowed* with this service. Useful, but random | |
// source: http://www.maxmind.com/app/javascript_city | |
// The source is open source, as per: http://www.maxmind.com/app/api, but doesn't discuss specific license use. Hopefully it's just free to use - yay internet! | |
var geourl = 'http://j.maxmind.com/app/geoip.js_' + Math.random(), | |
iframe = document.createElement('iframe'), | |
doc, win; |
This file contains hidden or 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
<?php | |
/** | |
* A little Object Relational Mapper in PHP | |
* @author [email protected] | |
*/ | |
class Post | |
{ | |
public $title; |
This file contains hidden or 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
# Install virtualenv | |
sudo pip install virtualenv | |
# Create the virtual environment | |
virtualenv sandbox | |
# Play around with Python inside the new 'sandbox' | |
cd sandbox | |
./bin/python | |
cd .. |
This file contains hidden or 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
#pseudo code | |
#option 1 | |
class User: | |
screen_name = '' | |
email = '' | |
class UserManager: | |
def validate(user): | |
if user.screen_name == '': |
This file contains hidden or 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
<?php | |
$english = arr( | |
strr('Hello X'), | |
strr('Goodbye X') | |
); | |
$pirate = $english | |
->replace('/Hello/', 'Avast') | |
->replace('/Goodbye/', 'Was good te see ye') |
This file contains hidden or 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
math:{ | |
add: (a,b)-> a+b | |
mean: (data)-> | |
data.reduce(math.add) / data.length | |
square: (x)-> x*x | |
sqrt: Math.sqrt | |
sum: (data)-> data.reduce(math.add) | |
stddev: (data)-> | |
_mean: math.mean(data) | |
_dev_from_mean: (i-_mean) for i in data |
OlderNewer