Skip to content

Instantly share code, notes, and snippets.

View ottbot's full-sized avatar

Robert Crim ottbot

View GitHub Profile
class Staff < Sequel::Model(:staff)
require 'sequel/extensions/pagination'
def box_times
if box
box.split(';#')
else
[]
end
rob@cosmo kiva (master) $ gfortran -o kiva3v *.F
begin.F:51.18:
call second(tstart)
1
Error: 'time' argument of 'second' intrinsic at (1) must be of kind 4
exitk.F:32.19:
call second (tfinish)
1
month = 5
year = 2009
century = (year - (year % 100))/100
century_offset = ((39 - century) % 4) * 2
is_leap = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0
year_offset = ((year % 100) + (year % 100)/4) % 7
class Story < Sequel::Model
require 'image_science'
attr_accessor :photo_upload
def after_save
super
process_upload!
end
require 'sinatra/base'
module Sinatra
module Editable
def self.registered(app)
app.set :editable_route, '/editable'
app.get "#{options.editable_route}/*" do
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
@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.;
@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 / 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 / .gitignore
Created January 29, 2013 11:33 — forked from karmi/.gitignore
.DS_Store
Gemfile.lock
*.pem
node.json
tmp/*
!tmp/.gitignore