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
<?php | |
/** | |
* Check for post format type, apply filter based on post format name for easy modification. | |
* | |
* @since 1.0 | |
*/ | |
function chimps_post_formats_content() { | |
$format = get_post_format(); | |
$root = get_template_directory_uri(); | |
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
# Update, upgrade and install development tools: | |
apt-get update | |
apt-get -y upgrade | |
apt-get -y install build-essential | |
apt-get -y install git-core | |
# Install rbenv | |
git clone git://github.com/sstephenson/rbenv.git /usr/local/rbenv | |
# Add rbenv to the path: |
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
ruby-1.9.2-p180:001:0>> qb(10**6) { Math.log10(123456789).floor + 1 } | |
Rehearsal ------------------------------------ | |
1.120000 0.000000 1.120000 ( 1.100062) | |
--------------------------- total: 1.120000sec | |
user system total real | |
1.090000 0.000000 1.090000 ( 1.085366) | |
# => nil | |
ruby-1.9.2-p180:002:0>> qb(10**6) { 123456789.to_s.size } | |
Rehearsal ------------------------------------ |
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
require 'httparty' | |
class HTTP | |
include HTTParty | |
def initialize uri | |
self.class.base_uri uri | |
end | |
end | |
class Dropbox < HTTP |
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
pry(main)> module Blah | |
pry(main)* def blah | |
pry(main)* true | |
pry(main)* end | |
pry(main)* end | |
=> nil | |
pry(main)> a = [] | |
=> [] | |
pry(main)> Enumerable.send(:include, Blah) | |
=> Enumerable |
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
pry(Ripper)> sexp %q{"foo\nbar"} | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo\\nbar", [1, 1]]]]]] | |
pry(Ripper)> sexp %q{'foo\nbar'} | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo\\nbar", [1, 1]]]]]] | |
pry(Ripper)> sexp %q{'foo\nbar'} | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo\\nbar", [1, 1]]]]]] | |
pry(Ripper)> sexp %q{'foo\\nbar'} | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo\\nbar", [1, 1]]]]]] | |
pry(Ripper)> sexp %q{"foo\\nbar"} | |
=> [:program, [[:string_literal, [:string_content, [:@tstring_content, "foo\\nbar", [1, 1]]]]]] |
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
#! /usr/bin/env python | |
# vim: set fileencoding=utf-8 | |
# (c) Uwe Kleine-König <[email protected]> | |
# GPLv2 | |
# Modified by Utkarsh Kukreti <[email protected]> - 2011/05/31 | |
import locale | |
import sys | |
f = file(sys.argv[1]) |
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
# Save as Rakefile, and run `rake watch` | |
def recompile(base, relative) | |
haml = File.join(base, relative) | |
html = File.join(base, relative.gsub(/\.haml$/, '.html')) | |
print ">>> Change detected to #{relative} >> " | |
system "haml", haml, html | |
puts "Compiled <<<" | |
end | |
desc "Watch HAML files for changes" |
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
[od]$ rails c | |
Loading development environment (Rails 3.0.6) | |
ruby-1.9.2-p180 :001 > Deparment.all | |
=> #<Mongoid::Criteria | |
selector: {}, | |
options: {}, | |
class: Deparment, | |
embedded: false> | |
ruby-1.9.2-p180 :002 > Deparment.all.entries |
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 setup() | |
Mongoid.configure do |config| | |
config.master = Mongo::Connection.new.db("testbooks") | |
end | |
@book = Books.create(title: 'Turn of a Screw', author: "Henry James", barcode: '666') | |
end | |
def test_barcode | |
# Test for uniqueness of each book barcode |