This file contains hidden or 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 Gender | |
| include Comparable | |
| attr_reader :gender | |
| VALID_ENUMS = [:male, :female] | |
| def initialize(value) | |
| value = value.to_s.downcase.to_sym | |
| @gender = value if VALID_ENUMS.include?(value) | |
| end |
This file contains hidden or 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 'find' | |
| PATTERN = Regexp.new '(\r\n\r\n)?<script>[^\n]+</script>\n<!--[a-f0-9]{32}-->' | |
| def kill_virus(dir) | |
| Find.find(dir) do |path| | |
| if File.file?(path) | |
| text = File.read(path) | |
| if text =~ PATTERN |
This file contains hidden or 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
| # prompt for showing current git branch and dirty state: | |
| __git_branch_status() { | |
| local b | |
| local d | |
| if ! [[ $(git status 2> /dev/null) ]]; then | |
| return | |
| fi | |
| if ! b="$(git symbolic-ref HEAD 2>/dev/null)"; then | |
| if ! b="$(git describe --exact-match HEAD 2>/dev/null)"; then | |
| b="$(git rev-parse 2>/dev/null | cut -c1-7)..." |
This file contains hidden or 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
| andrew@feldspar ~/Sites/pemberton(master) $ git branch -r | |
| trunk | |
| trunk@289 | |
| whistler/php | |
| whistler/trunk | |
| whistler/wlpsite | |
| whistler/wlpsite@42 | |
| andrew@feldspar ~/Sites/pemberton(master) $ git co -b whistler/master whistler/trunk | |
| Switched to a new branch 'whistler/master' |
This file contains hidden or 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
| # Deflate | |
| AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript | |
| BrowserMatch ^Mozilla/4 gzip-only-text/html | |
| BrowserMatch ^Mozilla/4.0[678] no-gzip | |
| BrowserMatch bMSIE !no-gzip !gzip-only-text/html | |
| DeflateCompressionLevel 9 | |
| SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0 |
This file contains hidden or 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
| # Ok, this is just a simplified example: | |
| @parent.children.all_passing? # => true or false | |
| # I want a method that returns something based on the collection of | |
| # associated objects. Using association extensions, I can put a | |
| # method on the has_many in parent model: | |
| class Parent < ActiveRecord::Base |
This file contains hidden or 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
| # Before, I was overriding the initialize method to set the run_date. | |
| # This is how I'm doing it now: | |
| class ListingHighlight < ActiveRecord::Base | |
| before_validation :assign_run_date | |
| validates_presence_of :run_date, :on => :create | |
| def run_date=( value ) | |
| write_attribute :run_date, some_date_method(value) |
This file contains hidden or 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 http://www.awayback.com/revised-font-stack/ | |
| // | |
| // Each stack has the survey statistics and any additional notes in '[]'. | |
| // Stacks are ordered in Window > cross-platform > Mac | |
| // | |
| // Serif Font Stacks | |
| // Cambria (54.51% on Windows) |
This file contains hidden or 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
| # Key bindings | |
| # To see the key combo you want to use just do: | |
| # $ read | |
| # And press it | |
| bind '"^[[D": backward-word' # option left | |
| bind '"^[[C": forward-word' # option right |
This file contains hidden or 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 File.dirname(__FILE__) + '/../test_helper' | |
| require 'compass/test_case' | |
| class StylesheetsTest < Compass::TestCase | |
| class << self | |
| def sass_files(path) | |
| Dir.glob(File.join(path, "**", "[^_]*.sass")) | |
| end | |
| def test_stylesheet(sass_file, &block) |