Skip to content

Instantly share code, notes, and snippets.

View bullfight's full-sized avatar
🚀

Patrick Schmitz bullfight

🚀
View GitHub Profile
require "rubygems"
require "net/http"
require "open-uri"
data = open("http://cdo.ncdc.noaa.gov/climatenormals/clim84/IL/IL110055.txt").map
#data = open("http://cdo.ncdc.noaa.gov/climatenormals/clim84/IL/IL112679.txt").map
metric = {}
metric[:station_coop_id] = data[4][44..49]
extract.formula<-function(formu){
if (!is(formu,"formula"))
stop("X should be a valid formula of form \n y ~ x1 + x2 | conditional")
resp <- formu[[2]]
if( length(formu[[3]]) < 2 ){ formu <- formu }else{ formu <- formu[[3]] }
flattener <- function(f) {if (length(f)<3) return(f);
c(Recall(f[[2]]),Recall(f[[3]]))}
if (formu[[1]] == '|'){
# Module containing a collect_kv method to allow
# a new hash to be generated my collect instead
# of returning an array of modified keys or values
module CollectKeyValue
# Takes a block that returns a [key, value] pair
# and builds a new hash based on those pairs
def collect_kv
result = {}
each do |k,v|
@bullfight
bullfight / gist:946491
Created April 28, 2011 14:48
protovis update data
var minnesota = [{name:"job 1", values:[182904,196530,203944,192492,77393,81243]}];
$(document).ready(function(){
$("button").click(function(){
minnesota = [{name:"changed job", values:[342,34234,2342,543]}];
draw();
});
});
# create rvmrc file
create_file ".rvmrc", "rvm gemset use #{app_name}"
gem "haml-rails"
gem "sass"
# hpricot and ruby_parser required by haml
gem "hpricot", :group => :development
gem "ruby_parser", :group => :development
gem "nifty-generators"
gem "simple_form"
<html>
<head>
<script>
document.onclick = function(evt) {
var el = window.event? event.srcElement : evt.target;
if (el && el.className == "unselected") {
el.className = "selected";
var siblings = el.parentNode.childNodes;
for (var i = 0, l = siblings.length; i < l; i++) {
var sib = siblings[i];
@bullfight
bullfight / gist:1031181
Created June 17, 2011 10:27
@each multiple lists?
$nav_elements: home, bio, shows, music, video, photos, store;
$nav_element_positions: 86px, 55px, 62px, 82px, 88px, 103px, 94px;
@each $element,$position in $nav_elements,$nav_element_positions {
ul li.nav_#{$element} a {
width: $position; }
}
@bullfight
bullfight / style.css
Created June 17, 2011 11:32
Menu CSS to SCSS
/* =Menu
-------------------------------------------------------------- */
div.menu { width: 570px; height: 72px; float: left; margin: 0 auto; padding: 22px 0 0 0; }
div.menu ul { width: 570px; height: 33px; margin: 0; padding: 0; float: left; background: url("images/mainnav.gif") no-repeat top left; }
div.menu ul li { list-style-type: none; float: left; margin: 0; padding: 0; display: inline; height: 33px; }
div.menu ul li a { display: block; height: 33px; text-indent: -9999px; outline: none; margin: 0; }
div.menu ul li.nav_home a { width: 86px; }
div.menu ul li.nav_bio a { width: 55px; }
div.menu ul li.nav_shows a { width: 62px; }
/* =Menu
-------------------------------------------------------------- */
div.menu { width: 570px; height: 72px; float: left; margin: 0 auto; padding: 22px 0 0 0; }
div.menu ul { width: 570px; height: 33px; margin: 0; padding: 0; float: left; background: url("images/mainnav.gif") no-repeat top left; }
div.menu ul li { list-style-type: none; float: left; margin: 0; padding: 0; display: inline; height: 33px; }
div.menu ul li a { display: block; height: 33px; text-indent: -9999px; outline: none; margin: 0; }
div.menu ul li.nav_home a { width: 86px; }
div.menu ul li.nav_bio a { width: 55px; }
div.menu ul li.nav_shows a { width: 62px; }
= render :partial => 'shared/feed_item', :collection => @feed_items
.pagination
= link_to_next_page @feed_items, "More", :remote => true