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
| $start-color:#2B73A2; | |
| $number: 12; | |
| @for $i from 1 through $number { | |
| .label-#{$i} { | |
| color:adjust_hue($start-color, ($i - 1) * (360 / $number)); | |
| } | |
| } |
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
| # Sledgehammer approach for ^Cing rake test runs | |
| if Rails.env.test? | |
| if `ps -wwp #{Process.ppid}` =~ /ruby/ | |
| trap("INT") { | |
| Process.kill("KILL", Process.ppid) | |
| Process.kill("KILL", Process.pid) | |
| } | |
| 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
| class PostsController < ActionController::Base | |
| def create | |
| Post.create(post_params) | |
| end | |
| def update | |
| Post.find(params[:id]).update_attributes!(post_params) | |
| end | |
| private |
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 MethodInterception | |
| def method_added(meth) | |
| return unless (@intercepted_methods ||= []).include?(meth) && !@recursing | |
| @recursing = true # protect against infinite recursion | |
| old_meth = instance_method(meth) | |
| define_method(meth) do |*args, &block| | |
| puts 'before' | |
| old_meth.bind(self).call(*args, &block) |
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 'integration_helper' | |
| require 'rack' | |
| require 'rack/handler/webrick' | |
| describe HttpClient do | |
| before :all do | |
| @server = WEBrick::HTTPServer.new( | |
| :Port => 9293, | |
| :Logger => Rails.logger, | |
| :AccessLog => Rails.logger |
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
| <?php | |
| // Usage: Drop this script in _import and then run `php import.php` | |
| // It will import posts from WordPress as markdown | |
| // EDIT THESE | |
| ini_set('date.timezone', 'America/New_York'); | |
| $con = mysql_connect('localhost', 'root', ''); | |
| $db = mysql_select_db('blog_test'); | |
| $q = mysql_query("SELECT * FROM blog_posts"); |
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
| # Add this to your spec_helper.rb | |
| RSpec.configure do |config| | |
| config.treat_symbols_as_metadata_keys_with_true_values = true | |
| config.around(:each, :vcr) do |example| | |
| name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/") | |
| VCR.use_cassette(name, :record => :new_episodes) do | |
| example.call | |
| end | |
| 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
| # add this to your spec helper | |
| RSpec.configure do |config| | |
| config.treat_symbols_as_metadata_keys_with_true_values = true | |
| config.filter_run :focus => true | |
| config.run_all_when_everything_filtered = true | |
| end | |
| # and then use the :focus tag in your specs | |
| it "does something awesome", :focus do |
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
| Original Source: https://github.com/chneukirchen/styleguide | |
| = Christian Neukirchen's Ruby Style Guide | |
| You may not like all rules presented here, but they work very well for | |
| me and have helped producing high quality code. Everyone is free to | |
| code however they want, write and follow their own style guides, but | |
| when you contribute to my code, please follow these rules: | |
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 AttrReaderWriter | |
| def attr_reader_or_writer(*keys) | |
| keys.flatten.each do |key| | |
| class_eval <<-RUBY, __FILE__, __LINE__ | |
| def #{key}(val = nil) | |
| @#{key} = val || @#{key} | |
| end | |
| RUBY | |
| end | |
| end |