Madison Ruby Conf Stretches
- extend one arm forward, flex hand up(like stop sign), use other hands to pull fingers back toward body. then flex hand down and pull fingers toward body. do both sides
module FizzBuzzC | |
%default total | |
-- Dependently typed FizzBuzz, constructively | |
-- A number is fizzy if it is evenly divisible by 3 | |
data Fizzy : Nat -> Type where | |
ZeroFizzy : Fizzy 0 | |
Fizz : Fizzy n -> Fizzy (3 + n) |
(create-circuit :test) | |
(create-channel :tweets) | |
(create-device :tweeter-1 as :tweeter | |
(filters ["ukraine" "russia" "putin" "news" "crimea"])) | |
(create-device :tweet-channel as :channeler | |
(channel :tweets)) | |
(create-wire-> |
require 'formula' | |
class IcarusVerilog < Formula | |
homepage 'http://iverilog.icarus.com/' | |
url 'http://hivelocity.dl.sourceforge.net/project/iverilog/iverilog/0.9.6/verilog-0.9.6.tar.gz' | |
sha1 'd81f586b801a2d897ba8c35971d660b960220ed4' | |
head 'https://github.com/steveicarus/iverilog.git' | |
if build.head? |
type InitFunction func() (interface{}, error) | |
type ConnectionPoolWrapper struct { | |
size int | |
conn chan interface{} | |
} | |
/** | |
Call the init function size times. If the init function fails during any call, then | |
the creation of the pool is considered a failure. |
(defn sumo | |
([l n] (sumo l 0 n)) | |
([l acc n] | |
(matche [l] | |
([[]] (fd/== acc n)) | |
([[x . r]] | |
(fresh [nacc] | |
(fd/in x (fd/interval 0 1)) | |
(fd/+ acc x nacc) | |
(sumo r nacc n)))))) |
fizz = [nil, nil, "Fizz"].cycle.take(100) | |
buzz = [nil, nil, nil, nil, "Buzz"].cycle.take(100) | |
numbers = 1..100 | |
numbers.zip(fizz, buzz) do |n, f, b| | |
fizzbuzz = [f, b].join | |
puts(fizzbuzz.empty? ? n : fizzbuzz) | |
end |
# ruby 1.9 supports 4 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby) | |
# | |
# turns out, you can also call a proc via proc === :arg -- which means you can use proc's in when clauses! | |
# ruby doc: http://ruby-doc.org/ruby-1.9/classes/Proc.html#M001165 | |
# | |
# ... kudos to @chadfowler for the tip! | |
# | |
# (note: works on 1.8.7 as well :-)) | |
def am_i_awesome? |
#!/usr/bin/env ruby | |
require 'open-uri' | |
category = ARGV[0] || 'fail' | |
url = "http://api.cheezburger.com/xml/category/#{category}/lol/random" | |
open(url) do |f| | |
xml = f.read | |
if xml =~ /LolImageUrl\>([^\<]*)/m |
module Searchable | |
def self.searchable_fields | |
[] | |
end | |
def self.included(klass) | |
klass.named_scope :by_search, lambda {|q, options| | |
if q.present? | |
search_text = [klass.searchable_fields].flatten.collect {|f| |