An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
| #!/usr/bin/env ruby | |
| require "rubygems" | |
| require "hpricot" | |
| require "open-uri" | |
| url = "http://feeds.feedburner.com/Rubyconf2008-Confreaks" | |
| (Hpricot(open url)/:enclosure).map {|x| x.attributes["url"]}.uniq.each do |vid| | |
| File.exist?(vid.split("/").last) ? next : `wget #{vid}` |
| def create | |
| @ticket = Ticket.new(params[:ticket]) | |
| flash[:notice] = "Ticket created." | |
| redirect_to(@ticket) | |
| end | |
| def validate | |
| errors.add("No such category") unless self.category | |
| end |
| controller: | |
| def show | |
| begin | |
| asset = Attachment.find(params[:id]).asset | |
| render :text => "#{asset.path} #{asset.content_type} #{asset.original_filename}" | |
| rescue | |
| session_redirect | |
| end |
| # Trace is a model in vendor/plugins/mylogger/lib/app/models/trace.rb | |
| # vendor/plugins/mylogger/lib/mylogger.rb | |
| #... | |
| module MyLoggerImpl | |
| def self.trace(controller_instance) | |
| puts 'Tracing' |
| %h1 New document | |
| %table | |
| %tr | |
| %th | |
| %th | |
| %th | |
| - @documents.each do |document| | |
| %tr | |
| %th= link_to 'Show', document |
An implementation of Conway's Game of Life in 140 characters of Ruby.
Created by Simon Ernst (@sier).
| #!/usr/bin/env sh | |
| ## | |
| # This is script with usefull tips taken from: | |
| # https://github.com/mathiasbynens/dotfiles/blob/master/.osx | |
| # | |
| # install it: | |
| # curl -sL https://raw.github.com/gist/2108403/hack.sh | sh | |
| # |
| (define new-pi 3.1415926) | |
| (define days-in-year 365) | |
| (define (sqrt-t days-to-expiration) | |
| (sqrt (/ days-to-expiration days-in-year))) | |
| (define (normal-dist zz) | |
| (if (= zz 0) 0.5 | |
| [let ((p 0.2316419) (b1 0.31938153) (b2 -0.356563782) |
| #!/bin/env ruby | |
| def broken | |
| people = Hash.new([]) | |
| people['a'] = [1] | |
| people['b'] = [2] | |
| p people | |
| end | |
| broken |
| # all upcoming events for a client | |
| def future_events_all_accounts | |
| self.accounts.map{ |account| | |
| account.events.in_future(account.now).where(:client_id => self.id) | |
| }.uniq.sort_by{ |a| a.start_time } | |
| end | |
| # all past events for a client | |
| def past_events_all_accounts | |
| self.accounts.map{ |account| |