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 SomeModel < ActiveRecord::Base | |
| ... | |
| def render_pdf | |
| ac = ApplicationController.new | |
| ac.instance_variable_set("@some_variable_needed_in_template", some_variable) | |
| pdf = ac.render_to_string(pdf: "the_pdf_filename", template: 'pdf_templates/filename') | |
| 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
| $LOADED_FEATURES.select { |f| f =~ /time/ } #=> [] | |
| require 'time' #=> true | |
| $LOADED_FEATURES.select { |f| f =~ /time/ } #=> ["/Users/phil/.rbenv/versions/1.9.3-p194/lib/ruby/1.9.1/time.rb"] |
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
| #!/bin/bash | |
| while read oldrev newrev ref | |
| do | |
| echo "$oldrev $newrev $ref" | |
| done |
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 'test_helper' | |
| # testing rake task app:awesome_report | |
| # defined in file lib/tasks/app/awesome_report.rake | |
| describe 'App::AwesomeReportTaskTest' do | |
| it 'generates the awesomeness report' do | |
| subject.invoke | |
| assert File.exists?('awesomeness_report.csv') | |
| 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
| require 'fileutils' | |
| exit if FileTest.exist?('lock.file') | |
| # create a lock | |
| FileUtils.touch('lock.file') | |
| # do some work | |
| sleep 30 |
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
| Vagrant.configure("2") do |config| | |
| config.vm.box = "precise64" | |
| config.vm.box_url = "http://files.vagrantup.com/precise64.box" | |
| # Forward Riak port | |
| config.vm.network :forwarded_port, guest: 8098, host: 8098 | |
| # Provision with Puppet | |
| config.vm.provision :puppet, module_path: "puppet/modules" do |puppet| | |
| puppet.manifests_path = "puppet/manifests" |
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
| var _ = require("underscore") | |
| var res = [] | |
| var arr = [ | |
| {'id':21 ,'name' : 'name1' ,'vehiclename' : 'vehicle1' ,'parentid' : 21}, | |
| {'id':21 ,'name' : 'name1' ,'vehiclename' : 'vehicle2' ,'parentid' : 21}, | |
| {'id':22 ,'name' : 'name2' ,'vehiclename' : 'vehicle1' ,'parentid' : 22}, | |
| {'id':22 ,'name' : 'name2' ,'vehiclename' : 'vehicle2' ,'parentid' : 22}, | |
| ] |
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
| var db = require("riak-js").getClient() | |
| var async = require("async") | |
| var kvPairs = [ | |
| { key: "foo0", value: { somthing: "else0" } }, | |
| { key: "foo1", value: { somthing: "else1" } }, | |
| { key: "foo2", value: { somthing: "else2" } }, | |
| { key: "foo3", value: { somthing: "else3" } }, | |
| { key: "foo4", value: { somthing: "else4" } }, | |
| { key: "foo5", value: { somthing: "else5" } }, |
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
| #!/bin/bash | |
| echo "I do work!" |
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
| def code_from_markdown file | |
| content = File.read(file) | |
| code_snippets = [] | |
| content.scan(/`{3,}ruby\n((.|\n)*?)^`{3,}/) { |m| code_snippets << $1 } | |
| code_snippets | |
| end | |
| namespace :test do | |
| # all code inside ```ruby ``` is executed to uncomment certain examples just | |
| # use ```xruby ``` or alike |