This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'rubygame' | |
Rubygame::TTF.setup | |
class Game | |
def initialize | |
@screen = Rubygame::Screen.new [640, 480], 0, [Rubygame::HWSURFACE, Rubygame::DOUBLEBUF] | |
@screen.title = "Pung" | |
@queue = Rubygame::EventQueue.new |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
gem 'bluecloth', '>= 2.0.0' | |
require 'bluecloth' | |
require 'trollop' | |
opts = Trollop::options do | |
opt :in, "The file to parse", :default => 'markdown.txt' | |
opt :out, "The file to output to", :default => 'markdown.html' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: "ruby heyjude.rb [verses] [output file]" | |
# Inspired by the flowchart at http://loveallthis.tumblr.com/post/166124704 | |
def heyJude(n, fileName) | |
f = File.new(fileName, 'w') | |
n.times do |run| | |
f.syswrite "Hey Jude, " | |
if run % 3 == 1 | |
f.syswrite "don't make it bad\n" | |
f.syswrite "take a sad song and make it better\n\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import * | |
# The Task class, this is the main part of the program and contains several | |
# methods which can be used to manage individual task objects | |
class Task: | |
# Creates a new instance of the the Task object | |
# We're only assigning a title here to keep with the philosophy of minimal | |
# time expendature in creating new tasks | |
def __init__(self, title): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
import operator | |
import csv | |
class TaskHandler(object): | |
def __init__( self, *tasks ): | |
self.tasks = list(tasks) | |
def __repr__(self): | |
return "\n".join(map(str, (self.sorted()))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Temperature < Numeric | |
def initialize(temp) | |
@temp = temp | |
super | |
end | |
def to_farenheit | |
9 / 5 * (@temp + 32) | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS C:\Users\Rhys\code\first_app> heroku logs | |
/usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require': no such file to load -- sqlite3 (LoadError) | |
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:64:in `require' | |
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:62:in `each' | |
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:62:in `require' | |
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:51:in `each' | |
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:51:in `require' | |
from /usr/ruby1.8.7/lib/ruby/gems/1.8/gems/bundler-1.0.0/lib/bundler.rb:112:in `require' | |
from /disk1/home/slugs/297198_7b1fa3a_b1ba/mnt/config/application.rb:7 | |
from /usr/ruby1.8.7/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# A sample game using and MVC event driven pattern | |
import pygame # I for one welcome our new PyGame overlords | |
from pygame.locals import * | |
DIRECTION_UP = 0 | |
DIRECTION_DOWN = 1 | |
DIRECTION_LEFT = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'erb' | |
require 'rss/1.0' | |
require 'rss/2.0' | |
require 'open-uri' | |
helpers do | |
def open_rss | |
source = "http://daringfireball.net/feeds/articles" | |
content = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rss/2.0' | |
require 'open-uri' | |
open('http://feeds.feedburner.com/RubyInside') do |http| | |
response = http.read | |
puts response | |
result = RSS::Parser.parse(response, false) | |
puts "Channel: " + result.channel.title | |
result.items.each_with_index do |item, i| | |
puts "#{i+1}. #{item.title}" if i < 20 | |
end |
OlderNewer