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
| {8:55}[ruby-1.9.2]~/code/si_kepler_data_convertor ben% ruby convertor.rb data/* | |
| Processing file data/kplr001432149-2009131105131_llc_wg4.dat | |
| Finished processing file data/kplr001432149-2009131105131_llc_wg4.dat | |
| Processing file data/kplr001432149-2009131105131_llc_wg4copy.dat | |
| convertor.rb:34:in `block in convert_from_string!': wrong argument type Object (expected Data) (TypeError) | |
| from convertor.rb:34:in `map!' | |
| from convertor.rb:34:in `convert_from_string!' | |
| from convertor.rb:13:in `convert!' | |
| from convertor.rb:91:in `block in <main>' | |
| from convertor.rb:89:in `each' |
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
| resources :blogs do | |
| get :management, :on => :member | |
| 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
| def bildstream | |
| require 'net/http' | |
| Net::HTTP.start '192.l68.37.100' do |http| | |
| req = Net::HTTP::Get.new '/image/monitor/local_pict1.jpg' | |
| req.basic_auth 'admin', '' | |
| open "public/local_pict1.jpg", "wb" { |file| file.write http.request(req).body } | |
| 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
| protected | |
| def permission_denied | |
| flash[:error] = t :access_denied | |
| respond_to do |format| | |
| format.html { redirect_to(:back) rescue redirect_to(root_url) } | |
| format.xml { head :forbidden } | |
| format.json { head :forbidden } | |
| 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
| >> params = { "user" => { "notification_ids" => "blah" } } | |
| => {"user"=>{"notification_ids"=>"blah"}} | |
| >> params["user"].has_key? "notification_ids" if params["user"] | |
| => true | |
| >> params = {} | |
| => {} | |
| >> params["user"].has_key? "notification_ids" if params["user"] | |
| => nil |
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 self.to_config | |
| self.all.map { |q| q.to_config }.join("\n").insert 0, <<-EOS | |
| [general] | |
| setinterfacevar=yes | |
| setqueueenteryvar=yes | |
| setqueuevar=yes | |
| eventwhencalled=yes | |
| eventmemberstatus=yes | |
| EOS |
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
| development: | |
| adapter: mysql | |
| host: 127.0.0.1 | |
| database: database | |
| username: username | |
| password: password |
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
| >> "somestring"[0] | |
| => "s" # in Ruby 1.9.2 | |
| => 115 # in Ruby 1.8.7 | |
| >> "somestring"[0,1] | |
| => "s" # in both 1.8.7 and 1.9.2 - backwards compatible |
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
| create_table :numbers do |t| | |
| t.string :phone_number | |
| end | |
| create_table :call_lists do |t| | |
| t.string :type | |
| t.string :name | |
| t.integer :user_id | |
| t.integer :county_id | |
| t.integer :state_id | |
| 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
| class Convertor | |
| def initialize(input_filename, force_overwrite) | |
| @input_filename = input_filename | |
| @force_overwrite = force_overwrite | |
| @input_data = [] | |
| end | |
| def convert! | |
| read_in_data | |
| split_comments! |