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 pascal(n) | |
| file = File.open("out.txt", "w") | |
| p=[1] | |
| while(p.length<n) | |
| file.write(p.join(" ")+"\n") | |
| p=Array.new(p.length+1) do |i| | |
| a=i<p.length ? p[i] : 0 | |
| b=i>0 ? p[i-1] : 0 | |
| a+b | |
| 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 'rubygems' | |
| require 'json' | |
| require 'open-uri' | |
| timeline = 'https://api.twitter.com/1/statuses/public_timeline.json' | |
| data = open(timeline) | |
| foo = Array.new | |
| result = JSON.parse(data.read) | |
| result.each do |r| | |
| if r['usernames'] || r['text'].match('ruby')) |
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
| %http://www.wired.com/geekdad/2011/11/geekdad-puzzle-of-the-weekwizards-and-mages-and-shamans-oh-my/ | |
| solucion(Sol):- Sol=[[gabdalf,_,falton,_],[_,_,_,mage],[_,_,_,necromancer],_,_], | |
| member([R1,human,dragonstorm,_],Sol), | |
| member([rokar,_,_,ilusionist],Sol), | |
| is_set([R1,rokar]), | |
| member([_,wood_elf,smeedly,_], Sol), | |
| member([malfor,HE,_,wizard],Sol), | |
| member([_,highelf,_,_],Sol), | |
| is_set([HE,highelf]), | |
| member([_,halforc,V,MA],Sol), |
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
| lala = {} | |
| img = Magick::Image::read('joker.bmp').first | |
| img.each_pixel do |bar, c, r| | |
| lala[bar]= 0 unless lala[bar] | |
| lala[bar] = lala[bar]+1 | |
| end | |
| lala |
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: { | |
| o avatar_url: http://s3.amazonaws.com/socialbooks-development/user/default | |
| o created_at: "2011-01-13T20:27:42Z" | |
| o location: null | |
| o following_count: 0 | |
| o updated_at: "2011-01-13T20:27:42Z" |
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
| maguilar@naru:~/tmp/getsocialbooks.com/config$ heroku rake db:populate --app social-books-dev | |
| (in /home/app/57f59070-ca2b-482a-a1f1-d3217190f3dd) | |
| Creating default users... | |
| Done. | |
| Creating default users... | |
| Done. | |
| Downloading dummy books... | |
| Creating books. This will take awhile... | |
| Creating book: machiavelli-prince.epub | |
| Creating book: wilde-picture-of-dorian-gray.epub |
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
| $ rake db:populate --trace | |
| (in /home/maguilar/getsocialbooks.com) | |
| ** Invoke db:populate (first_time) | |
| ** Invoke environment (first_time) | |
| ** Execute environment | |
| ** Execute db:populate | |
| Removing all old content... | |
| Creating users... | |
| Creating followings... | |
| rake aborted! |
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
| irb(main):021:0> ash = Book.serializable_hash_options | |
| => {:include=>{:authorships=>{:only=>["id", "author_id", "book_id", "created_at", "updated_at"]}}, :only=>[:id, :title, :created_at, :updated_at, :epub_checksum]} | |
| irb(main):022:0> ash2 | |
| => {:include=>{:spine_items=>{:only=>["id", "author_id", "book_id", "created_at", "updated_at"]}}} | |
| irb(main):023:0> ash.reverse_merge(ash2) | |
| => {:include=>{:authorships=>{:only=>["id", "author_id", "book_id", "created_at", "updated_at"]}}, :only=>[:id, :title, :created_at, :updated_at, :epub_checksum]} | |
| irb(main):024:0> ash.merge(ash2) |
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
| maguilar@naru:~/getsocialbooks.com$ rake jobs:work --trace | |
| (in /home/maguilar/getsocialbooks.com) | |
| ** Invoke jobs:work (first_time) | |
| ** Invoke merb_env (first_time) | |
| ** Execute merb_env | |
| ** Invoke environment (first_time) | |
| ** Execute environment | |
| ** Execute jobs:work | |
| *** Starting job worker host:naru pid:25747 | |
| rake aborted! |
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_controller.rb | |
| def show | |
| respond_to do |format| | |
| format.json { render :json => @user.to_json(:method => [:avatar_url])} | |
| end | |
| end |