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
def create | |
@album = Album.new(params[:album]) | |
if @album.save | |
@photo = Photo.new(params[:photo]) | |
@photo.album = @album | |
@photo.save | |
end | |
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
import twitter | |
import sys | |
from whoosh.fields import Schema, STORED, ID, KEYWORD, TEXT | |
import os, os.path | |
from whoosh import store, index | |
import shelve | |
from whoosh.qparser import QueryParser | |
from spambayes import hammie, Options, mboxutils, storage | |
from spambayes.Version import get_current_version | |
import email |
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
; HTTP query string parser, Clojure | |
(defn parse-query-string | |
"Parses a querystring into a hash" | |
[qs] | |
(into {} (map #(vec (.split % "=")) (.split qs "&")))) |
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
# Given a class with an array of files as paths e.g. | |
# ['path/to/file.txt', 'other/file','path/file','file'] | |
# Will organize them into a hash like | |
# { | |
# 'path' => { | |
# 'to' => { | |
# 'file' => {} | |
# }, | |
# 'file' => {} | |
# }, |
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
module ActiveSupport #:nodoc: | |
module CoreExtensions #:nodoc: | |
module Date #:nodoc: | |
# Enables the use of time calculations within Time itself | |
module Calculations | |
# Returns a new Date/DateTime representing the "start" of this week (i.e, Monday; DateTime objects will have time set to 0:00) | |
def beginning_of_week | |
days_to_monday = self.wday!=0 ? self.wday-1 : 6 | |
result = self - days_to_monday | |
self.acts_like?(:time) ? result.midnight : result |
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
<label>Blah</label> | |
<asp:Textbox id="something" runat="server"></asp:Textbox> | |
<div class="clear"></div> | |
TO | |
<div> | |
<label>Blah</label> | |
<asp:Textbox id="something" runat="server"></asp:Textbox> | |
</div> |
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 ruby | |
require 'mathn' | |
require 'benchmark' | |
class FindPrime | |
attr_accessor :limit | |
def initialize | |
@limit = 10001 | |
end | |
def display |
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
<input type="hidden" id="sortCol" name="sortCol"> | |
<xsl:attribute name="value"> | |
<xsl:choose> | |
<xsl:when test="//root/request/sortCol"> | |
<xsl:value-of select="//root/request/sortCol" /> | |
</xsl:when> | |
<xsl:otherwise>1</xsl:otherwise> | |
</xsl:choose> | |
</xsl:attribute> | |
</input> |
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 ruby | |
# | |
# A hook script to verify that only syntactically valid ruby code is commited. | |
# Called by git-commit with no arguments. The hook should | |
# exit with non-zero status after issuing an appropriate message if | |
# it wants to stop the commit. | |
# | |
# Put this code into a file called "pre-commit" inside your .git/hooks | |
# directory, and make sure it is executable ("chmod +x .git/hooks/pre-commit") | |
# |
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
# rvm 'gemdir' function, easily switch between any ruby's gem directory. | |
function gemdir { | |
if [ -z "$1" ] ; then | |
echo "gemdir expects a parameter, which should be a valid rvm ruby selector" | |
else | |
rvm use $1 | |
cd `rvm gemdir` | |
pwd | |
fi | |
} |