Skip to content

Instantly share code, notes, and snippets.

View ottbot's full-sized avatar

Robert Crim ottbot

View GitHub Profile
@ottbot
ottbot / throttle-example.clj
Last active August 29, 2015 14:23
throttling with manifold
(ns throttle-example
(:require [manifold.stream :as s]))
;; should limit to 1 per sec ?
(def a (s/throttle 1 (s/stream)))
(dotimes [n 100]
(s/put! a n))
(defn now []
@ottbot
ottbot / circle_ci_builds.clj
Created March 13, 2015 06:00
Get the number of builds made on Circle CI
(require '[clj-http.client :as client])
(def token "a-token")
(defn fetch-projects []
(:body
(client/get "https://circleci.com/api/v1/projects"
{:query-params {"circle-token" token}
:accept :json
:as :json})))

Keybase proof

I hereby claim:

  • I am ottbot on github.
  • I am robert (https://keybase.io/robert) on keybase.
  • I have a public key whose fingerprint is D9F9 5ED5 1DAF FB7A C478 9E5D 1A53 DA36 0447 9157

To claim this, I am signing this object:

@ottbot
ottbot / .gitignore
Created January 29, 2013 11:33 — forked from karmi/.gitignore
.DS_Store
Gemfile.lock
*.pem
node.json
tmp/*
!tmp/.gitignore
@ottbot
ottbot / install_homebrew.rb
Created March 1, 2012 10:16 — forked from mxcl/install_homebrew.markdown
Installs Homebrew to /usr/local so you don't need sudo to `brew install`
#!/usr/bin/ruby
# This script installs to /usr/local only. To install elsewhere you can just
# untar https://github.com/FundingCircle/homebrew/tarball/master anywhere you like.
module Tty extend self
def blue; bold 34; end
def white; bold 39; end
def red; underline 31; end
def reset; escape 0; end
def bold n; escape "1;#{n}" end
@ottbot
ottbot / php.rb
Created December 19, 2011 22:29
PHP Homebrew formula
require 'formula'
def mysql_installed?
`which mysql_config`.length > 0
end
class Php < Formula
url 'http://www.php.net/get/php-5.3.8.tar.gz/from/this/mirror'
homepage 'http://php.net/'
@ottbot
ottbot / gist:896073
Created March 31, 2011 09:07
dvm force calc
vi = w.vortices[step];
fx = -vi.gamma * (vi.y - vi.yI)/w.dt;
fy = -vi.gamma * (vi.xI - vi.x)/w.dt;
/* average with previous shed vortex */
if (step >= 1) {
vi = w.vortices[step - 1];
fx = (fx + (-vi.gamma * (vi.y - vi.yI)/w.dt))/2.;
fy = (fy + (-vi.gamma * (vi.xI - vi.x)/w.dt))/2.;
require 'rubygems'
require 'sequel'
DB = Sequel.connect('mysql://test:test@localhost/test') unless defined?(DB)
[:foos].each do |t|
DB.create_table? t do
primary_key :id
String :name
require 'sinatra/base'
module Sinatra
module Editable
def self.registered(app)
app.set :editable_route, '/editable'
app.get "#{options.editable_route}/*" do
class Story < Sequel::Model
require 'image_science'
attr_accessor :photo_upload
def after_save
super
process_upload!
end