Skip to content

Instantly share code, notes, and snippets.

View hackervera's full-sized avatar
😻

Veronika Tyler hackervera

😻
View GitHub Profile
;; Monty Hall problem (Let's Make a Deal gameshow)
;; http://www.marilynvossavant.com/articles/gameshow.html
(use '(incanter core stats charts))
;; set a simulation sample size
(def n 10000)
;; generate samples of initial-guesses, prize-doors, and switch decisions
(def initial-guesses (sample [1 2 3] :size n))
(def prize-doors (sample [1 2 3] :size n))
@aaronpk
aaronpk / json format for geo data
Created April 30, 2010 16:47
A JSON protocol for sharing and storing real-time data streams. Common use would be for sharing location data.
Common minimal format for sending just lat/long data
[
{
uuid: "550e8400-e29b-41d4-a716-446655440000",
date: "2010-04-30T16:50:00Z",
location: {
position: {
latitude: 45.5118,
longitude: -122.6433
}
<?php
$client = array('client_id' => 'geoloqi_web', 'client_secret' => '1234');
$post = array(
'grant_type' => 'password',
'username' => 'aaronpk',
'password' => '1234'
);
require 'json'
require 'isaac'
configure do |c|
c.nick = "icecondor"
c.server = "irc.freenode.net"
c.port = 6667
end
on :connect do
@nborwankar
nborwankar / nitin_jchris_evently_chat
Created August 13, 2010 01:45
Transcript of skype chat between Nitin Borwankar and J Chris Anderson
Nitin Borwankar: So big picture question that helps me understand why I should spend time grokking evently - two part question
Nitin Borwankar: a) why did you feel the need to create yet another framework b) what can I do with evently I couldn't do with
jQuery events etc?
Chris Anderson: evently was a natural consequence of using jquery
Chris Anderson: it just wraps up all the repetitive crap I kept doing in jquery, and does it automatically
Chris Anderson: so b) nothing
Nitin Borwankar: ok cool
Nitin Borwankar: second q
Chris Anderson: I think evently was discovered not invented
Nitin Borwankar: what are the component files of an evently minimal app (there's too much in a couchapp to tell what's essential
@hackervera
hackervera / gist:543455
Created August 22, 2010 07:04
build-couchdb geocouch
git checkout geocouch
(in /root/build-couchdb)
** Invoke default (first_time)
** Invoke couchdb:clean_install (first_time)
** Invoke couchdb:build (first_time)
** Invoke erlang:build (first_time)
** Invoke known_distro (first_time)
** Invoke known_mac (first_time)
** Execute known_mac
** Invoke known_ubuntu (first_time)
@igrigorik
igrigorik / webapp.rb
Created November 13, 2010 21:28
Inspired by @JEG2's talk at Rubyconf... Any ruby object, as a webapp! 'Cause we can. :-)
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
@aaronpk
aaronpk / gist:899244
Created April 2, 2011 05:02
Sending location data to the Geoloqi streaming server
require 'rubygems'
require 'socket'
socket = TCPSocket.new("stream.geoloqi.com", 40000)
puts socket.recv(100)
socket.write('your-access-token')
socket.flush
# The server outputs a confirmation message after connecting
puts socket.recv(1000)
@stuartsierra
stuartsierra / errors.clj
Created April 20, 2012 14:27
Example error messages from common mistakes with Datomic
;; Some example error messages resulting from common mistakes
;; using Datomic 0.8.4138
(ns errors
(:use [datomic.api :as d :only (db q)]))
(def uri "datomic:mem://database")
(d/create-database uri)
@stuarthalloway
stuarthalloway / gist:2645453
Created May 9, 2012 15:22
Datomic queries against Clojure collections
;; Datomic example code
(use '[datomic.api :only (db q) :as d])
;; ?answer binds a scalar
(q '[:find ?answer :in ?answer]
42)
;; of course you can bind more than one of anything
(q '[:find ?last ?first :in ?last ?first]
"Doe" "John")