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
| 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
| 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
| #Zero-width positive lookbehind | |
| "Enrico.Rubboli".match(/(?<=\.)(\w+)/) | |
| # => #<MatchData "Rubboli" 1:"Rubboli"> | |
| #Zero-width negative lookbehind | |
| "Enrico.Rubboli".match(/(?<!\.)(\w+)/) | |
| # => #<MatchData "Enrico" 1:"Enrico"> |
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
| re = /(?<nome>[\S]+)\s(?<cognome>[\S]+)/ | |
| result = re.match "Enrico Rubboli" | |
| #=> #<MatchData "Enrico Rubboli" nome:"Enrico" cognome:"Rubboli"> | |
| result[:nome] | |
| #=> "Enrico" | |
| "Enrico Rubboli".sub re, '\k<cognome> \k<nome>' | |
| #=> "Rubboli Enrico" |
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
| erubboli@kyoto:~/Progetti/clean-pm/new_design/clean_pm$ ruby -rubygems clean.rb | |
| erubboli@kyoto:~/Progetti/clean-pm/new_design/clean_pm$ | |
| erubboli@kyoto:~/Progetti/clean-pm/new_design/clean_pm$ gem list sinatra | |
| *** LOCAL GEMS *** | |
| sinatra (1.0) | |
| erubboli@kyoto:~/Progetti/clean-pm/new_design/clean_pm$ gem list rack |
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 ClientsController < ApplicationController | |
| respond_to :html, :xml, :json | |
| # [..] removed code [..] | |
| # DELETE /clients/1 | |
| # DELETE /clients/1.xml | |
| def destroy | |
| @client = Client.find(params[:id]) |
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 Leaf | |
| # ..omitted code.. | |
| def total_leafs | |
| 1 | |
| end | |
| end | |
| module Composite | |
| # .. omitted code.. | |
| def total_leafs |
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 City | |
| include Composite | |
| def initialize | |
| @children = [] | |
| end | |
| def count_children | |
| @children.lenght | |
| 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
| module Leaf | |
| def land_size | |
| @land_size || 0 | |
| end | |
| end | |
| module Composite | |
| def append_child(child) | |
| @children << child | |
| end |