Skip to content

Instantly share code, notes, and snippets.

View bullfight's full-sized avatar
🚀

Patrick Schmitz bullfight

🚀
View GitHub Profile
@bullfight
bullfight / ownum.exs
Created September 9, 2014 23:33
implementation of enum methods in elixir
defmodule Ownum do
def all?([], _fun), do: true
def all?([head | tail], fun) do
if fun.(head) do
all?(tail, fun)
else
false
end
end
#!/bin/bash
function remove_dir () {
rm -rf "$1_"
if [ -d "$1" ]
then
mv "$1" "$1_"
fi
}
@bullfight
bullfight / youtube_channel.rb
Created March 31, 2015 20:37
Read a Youtube channel
require 'rss'
class YoutubeChannel
Video = Struct.new(:response) do
def title
response.title
end
def uri_params
@bullfight
bullfight / seattle_rb.md
Last active August 29, 2015 14:23
Getting Started with Rails in Seattle

Community

Seattle's monthly and weekly meetup of the Rails community. This is a great way to get to know the local community and to see some excellent presentaions on software development both novice and advanced.

Essential Learning Tools

Work through this tutorial, it has concrete examples and will give you all the fundamental tools you need to build and deploy apps with ruby.

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];