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
User.include_root_in_json = true | |
User.first.to_json(:only => [:screen_name,:id]) | |
#=> {"user":{"id":1,"screen_name":"test"}} | |
User.include_root_in_json = false | |
User.first.to_json(:only => [:screen_name,:id]) | |
#=> {"id":1,"screen_name":"test"} |
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
res = `file "#{ARGV[0]}"` | |
#puts "#{ARGV[0]} -> #{res}" | |
if res.match /Microsoft/ | |
fn = ARGV[0].split('.') | |
fn[fn.size-1] = 'lit' | |
puts "mv \"#{ARGV[0]}\" \"#{fn.join('.')}\"" | |
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
parent.image.combine_options do |c| | |
c.fill hex_color | |
c.pointsize @obj.media.font_size | |
#c.font "#{RAILS_ROOT}/public/images/fonts/#{@obj.font.downcase}.ttf" | |
draw_params = '' | |
draw_params += "gravity #{gravity} " if gravity | |
#cmd += "scale #{scale},#{scale} " if scale | |
draw_params += "rotate #{degrees} " if degrees | |
##TODO: escape text characters!! |
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
<script> | |
function A() { | |
alert("new A called"); | |
this.my_method = function(element) { | |
alert("a#method called"); | |
} | |
}; | |
A.initialize = function() { | |
alert ("A#initialize called"); |
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 destroy | |
@journal = current_user.journals.find(params[:id]) | |
begin | |
Page.skip_callback(:save, :after, :run_rendering) | |
Page.skip_callback(:destroy, :before, :remove_from_list) | |
@journal.destroy | |
ensure | |
Page.set_callback(:save, :after, :run_rendering) | |
Page.set_callback(:destroy, :before, :remove_from_list) | |
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
mike@rbci:~$ psql -U postgres | |
psql (9.0.3) | |
Type "help" for help. | |
postgres=# update pg_database set datallowconn = TRUE where datname = 'template0'; | |
UPDATE 1 | |
postgres=# \c template0 | |
You are now connected to database "template0". | |
template0=# update pg_database set datistemplate = FALSE where datname = 'template1'; | |
UPDATE 1 |
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
POST /api/journals.json?authentication_token=RW6XUuI7hP0EnB4hZa0cjcsXLHkW1RhfXThhaKpen2nicMAsteU8gt1EgMoz HTTP/1.1 | |
Host: localhost:3000 | |
User-Agent: upage 0.8 (iPad Simulator; iPhone OS 4.3; en_US) | |
Content-Type: application/json;charset=utf-8;charset=utf-8 | |
Accept-Encoding: gzip | |
Accept: */* | |
Content-Length: 207 | |
Cookie: _upage-web_session=BAh7CEkiGXdhcmRlbi51c2VyLnVzZXIua2V5BjoGRVRbCEkiCVVzZXIGOwBGWwZpBkkiIiQyYSQxMCRzNnJxbkJaVFFvSDNIaTdNMEw5Mkp1BjsAVEkiHXdhcmRlbi51c2VyLnVzZXIuc2Vzc2lvbgY7AFR7BkkiFGxhc3RfcmVxdWVzdF9hdAY7AEZJdToJVGltZQ2rzhvAPaKZQAY6C0Bfem9uZSIIVVRDSSIPc2Vzc2lvbl9pZAY7AEYiJTIzYWNiMmU0NGM2NTYyNzcyNzlhZDdmNjgzNTYyNjlj--4ec972c052e55126acc68df354a0409b0142b2c6 | |
Connection: keep-alive |
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 'spec_helper' | |
describe 'rspec' do | |
it { true.should be_true } | |
it "mock methods" do | |
my_obj = double('obj', {:my_method => 2}) | |
my_obj.send('my_method').should == 2 | |
end | |
it "mock hyphen methods" 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> | |
<title>Auctions Test</title> | |
<script type="text/javascript" charset="utf-8" src="node_modules/faye/faye-browser.js"></script> | |
<script type="text/javascript" charset="utf-8" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.js"></script> | |
<script type="text/javascript" charset="utf-8"> | |
bayeux_client = new Faye.Client('http://localhost:8000/auctions'); |
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 'benchmark' | |
def a_method | |
10 | |
end | |
a_var = 10 | |
Benchmark.bm do |x| | |
x.report("variable access") do | |
for i in 0..200000000 do |