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
<a href="/foo.html" data-modal="#foo-modal">Foo</a> | |
<div id="foo-modal" class="modal"> | |
Hello! | |
</div> | |
<script> | |
$(function() { | |
$('a[data-modal]').on('click', function() { | |
$($(this).data('modal')).modal(); |
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
# Bayes filter for FotoJournal | |
if blog.title.contains('photography'): | |
blog.status = 'Active' | |
elif blog.title.contains('penis'): | |
blog.status = 'Spam' | |
else: | |
blog.status = 'Unknown' |
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 foo(bar): | |
return bar.baz() |
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
# It would be awesome if factory_girl let you specify multiple parent factories. | |
Factory.define :user do |f| | |
# normal factory definition ... | |
end | |
Factory.define :superuser, :parent => :user do |f| | |
f.is_superuser true | |
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
<!-- Old way: .themeContent has styles directly attached to it --> | |
<style type="text/css" media="screen"> | |
.themeContent { | |
margin-top: 300px; | |
width: 760px; | |
border: 1px solid #ff0066; | |
} | |
.themeContent h1 { ... } | |
.themeContent p { ... } | |
</style> |
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
/* Old: Because the editor doesn't have the .themeBody class, the editor | |
doesn't display the theme's font definition */ | |
body.themeBody{ | |
background:#ccc url({{ image_path_prefix }}bg.png) repeat-x; | |
margin:0; | |
font-family: "Lucida Grande", Arial, Helvetica, sans-serif; | |
} | |
/* New: the font styles will now apply to the editor as well */ |
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
# If the current directory is a git repository, this displays [branch_name] and, | |
# if there are uncommitted changes, an asterisk. | |
# Example: | |
# ~/projects/my_project[master*]: | |
# I should also point out this uses my own hot pink & teal shell colour scheme (best viewed on white background). | |
# Change the colours if you don't like pretty things. | |
function parse_git_dirty { |
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
# Very contrived example of how using class variables to hold expensive models/associations | |
# can drastically speed up tests when using Shoulda and FactoryGirl. | |
# | |
# One caveat is that your test cases are no longer truly isolated. That is, if your | |
# test case modifies one of the "cached" instances, subsequent test cases may be invalid. | |
# | |
# You should only store models as class variables if: | |
# 1) Your test cases do not modify their data, and | |
# 2) The data contained in the cached models isn't vital to your test case. | |
class TaskTest < ActiveSupport::TestCase |
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
# A StudentExam represents an Exam taken by a Student. | |
# It records the start/stop time, room number, etc. | |
class StudentExamTest < ActiveSupport::TestCase | |
should_belong_to :student | |
should_belong_to :exam | |
setup do | |
# These objects need to be created before we can create a StudentExam. Tests will NOT modify these objects. | |
# @school is a very time-expensive model to create (associations, external API calls, etc). |
OlderNewer