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
| If you can see this, I can embed gists on google plus. sweet! |
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
| stubDate = (date) -> | |
| @oldDate = Date | |
| Date = -> date | |
| resetStubDate = -> | |
| Date = @oldDate if @oldDate |
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
| module ApplicationHelper | |
| def controller_asset_javascript | |
| javascript_include_tag(controller_name) if Rails.configuration.assets.precompile.include?("#{controller_name}.js") || !Rails.env.production? | |
| end | |
| def controller_asset_stylesheet | |
| stylesheet_link_tag(controller_name) if Rails.configuration.assets.precompile.include?("#{controller_name}.css") || !Rails.env.production? | |
| end | |
| 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
| # Throw a comment in before and after every render call on html based templates | |
| module ActionView # :nodoc: all | |
| class Base | |
| alias_method :render_file_without_comments, :render | |
| attr_accessor :render_stack | |
| def render(options = {}, local_assigns = {}, &block) | |
| self.render_stack ||= [] | |
| if options[:partial] |
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
| # Run this with "coffee blackjack.coffee" | |
| _ = require('underscore') | |
| Array::remove = (e) -> this.splice(this.indexOf(e), 1) | |
| Array::clone = -> | |
| cloned = [] | |
| for i in this | |
| cloned.push i | |
| cloned |
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
| | stream | | |
| stream := WriteStream on: String new. | |
| SBApp fileOutOn: stream moveSource: false toFile: nil. | |
| stream contents. |
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
| # A goofy bit of code that takes your shoulda-style macro validations and generates a model class from it | |
| require 'rspec' | |
| require 'active_model' | |
| module ActiveRecordTranslator | |
| def it_should_validate_presence_of(field) | |
| klass = Class.new do | |
| include ActiveModel::Validations |
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 'rubygems' | |
| require 'nokogiri' | |
| require 'fileutils' | |
| site_root = File.expand_path('~/Sites/v42') | |
| Dir[site_root + '/**/*'].each do |full_path| | |
| next unless File.file?(full_path) | |
| old_name, extension = File.basename(full_path).split(".") | |
| doc = Nokogiri.parse(File.read(full_path)) |
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
| <html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | |
| <style type="text/css"><!-- | |
| body, table { background-color: #FFF; color:#333; font-family: arial, sans-serif; font-weight: 100; font-size: 12px; line-height: 150%; } | |
| .page_header { padding: 0px; } | |
| .page_title { font-size: 1.2em; font-weight: bold; padding: 5px; border-bottom: 1px dashed #999; } | |
| .feed_date { color: #777; font-size: 0.9em; font-weight: bold; } |
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 Hash | |
| def to_cgi_params | |
| map {|pair| [pair.first, CGI.escape(pair.last)].join('=')}.join('&') | |
| end | |
| end |