Skip to content

Instantly share code, notes, and snippets.

# post.rb
class Post < ActiveRecord::Base
has_attached_file :upload
validates_presence_of :title
end
# posts_controller.rb
data = grab_data_for(@post)
file = StringIO.new(data)
#container {
width: 680px;
margin: 2em auto;
}
.column {
float: left;
width: 60%;
padding: 2em 0;
}
id Container:
width = "680px"
margin = "2em auto"
class Column:
float = "left"
width = "60%"
padding = "2em 0"
= Ruby Packaging Standard
The aim of this document is to specify a common structure of how a
Ruby package distributed as source (that is, but not limited to,
development directories, version-controlled repositories, .tar.gz,
Gems, ...) should conform to.
(See RFC 2119 for use of MUST, SHOULD, SHALL.)
== Library files
"""Do common operations on dates"""
__author__ = "Jarod Luebbert ([email protected])"
__version__ = "$Revision: 0.0.1 $"
__date__ = "$Date: 2010/04/01 10:57PM $"
from math import ceil
class Date:
"Stores date information"
hash = Hash.new
arr = [1, 1, 1, 2, 2]
arr.compact.uniq.count {|a| hash[a] = arr.count(a)}
module MyModule
def self.hello
puts "hello"
end
end
MyModule.hello
# Hey coops..
#
# Imagine yourself on the other side of the table: two job openings, hundreds of resumes,
# _all of which_ look friggin' identical. Yeah, the HR departments at your MegaCorp XYZ are using
# automated tools to scan for keywords, and the coop department at your school is trying to beat
# you into submission to follow some "predefined template".. But, unless what you're aspiring to
# is to be an automaton at MegaCorp XYZ, relegated to writing test harnesses for code that will
# never see the light of day.. please do yourself a favor, and _be different_! Be bold, dammit.
#
# (Frankly, I'm falling asleep while reading your resumes.. Wake me up! Srsly.)
def generate_tour(tour)
url = "/wwtweb/xml2wtt.aspx"
xml = tour.to_xml
headers = {
"Content-Type" => "text/xml; charset=utf-8",
"Content-Length" => xml.size.to_s,
}
h = Net::HTTP.new("worldwidetelescope.org")
"""
Simple forking echo server built with Python's SocketServer library. A more
Pythonic version of http://gist.github.com/203520, which itself was inspired
by http://tomayko.com/writings/unicorn-is-unix.
"""
import os
import SocketServer
class EchoHandler(SocketServer.StreamRequestHandler):