rdp / ruby_beautifier Goto Github PK
View Code? Open in Web Editor NEWprettifier/beautifier for Ruby code [from http://www.arachnoid.com/ruby/] source reformatter packaged as a gem
prettifier/beautifier for Ruby code [from http://www.arachnoid.com/ruby/] source reformatter packaged as a gem
A ruby code beautifier/prettifier cleans ruby code for you [and give it the right indentation, etc.] What it does: you run rbeautify on poorly-aligned code, like def go if 3 stuff end end and it automatically converts said code to def go if 3 stuff end end Quite convenient for those of us who edit using editors without auto format. It also helps find indentation mismatches [i.e. missing end's and }'s ] by cleaning up the code so you can see scopes, and warning you where it sees mismatches [similar to ruby19 -w but better]. Many thanks to the original author [I just gemif-ied his existing script]. http://www.arachnoid.com/ruby/rubyBeautifier.html Installation: gem sources -a http://gems.github.com sudo gem install rogerdpack-rbeautify Usage: rbeautify <script name> Feedback welcome rogerdpack on github
class M; include IM; end
just call 'astyle' and warn if it doesn't exist.
input = <<-EOL # comments can go after a # on any line. "mutes" => [ "00:00:01.0", "00:00:02.0", "da..", ], "blank_outs" => [ "01:01:00.0" , "01:02:00.0", "violent scene of some sort" ], "disk_unique_id" => "#{md5}", "title" => "#{volume}", "dvd_title_track" => "1" # most DVD's use title 1 for the main film. Some don't though. The correct number is discoverable by opening the film in VLC and choosing "playback -> title" while watching the main feature. If its not 1, then change this here. EOL
class ParseFast def initialize filename @filename = filename end # currently returns full download time # # let's return a hash, like # {:download_time => [float or nil], :peer_bytes => x, :origin_bytes => y} # def go use_this_test_string = nil float = /\d+.\d+/ start_regex = /(#{float})._starting up logger/ end_regex = /(#{float})._DONE WITH WHOLE FILE/ ``` cs_straight = /#{float}.*cs straight.*just received (\d+)B/ bytes = [[cs_straight, :cs_straight]] starty = nil endy = nil stats = {} stats[:cs_straight] = 0 stats[:cs_p2p] = 0 (use_this_test_string || File.read(@filename)).lines {|line| if !starty && line =~ start_regex puts line, 'start line' if $VERBOSE starty = $1.to_f else begin # pesky encoding errors if !endy && line =~ end_regex puts line if $VERBOSE endy = $1.to_f else for regex, name in bytes if line =~ regex puts 'victory!' stats[name] += $1.to_i break # somewhat helpful... end end end rescue => e # encoding error... puts line, line.inspect end end } stats[:download_time] = if endy && starty puts endy - starty endy - starty ``` else nil end stats[:all_cs_bytes] = stats[:cs_straight] + stats[:cs_p2p] stats end end if **FILE** == $0 puts ParseFast.new(ARGV[0]).go end
long_value = {:assert_value_type => 'T_FIXNUM', :convert_values_from_ruby => "FIX2LONG",
:convert_values_to_ruby => "LONG2FIX", :value_type => "long"}
def focus_word(focus_segment) focus_world = '' char = focus_segment[-1..-1] while [")","]","}"].include?(char) char=focus_segment[-2..-2] focus_segment = focus_segment[0..-2] end j = focus_segment.length - 1 while !["\s","\t",";",",","(","[","{",">"].include?(char) && j >= 0 focus_world = "#{char}#{focus_world}" j=j-1 char = focus_segment[j..j] end focus_world end
promo = Promotion.find(
:first,
:conditions => ["code = ?", self.promotion_code]
)
puts File.dirname(FILE) + '/../test_helper'
require File.dirname(FILE) + '/../test_helper'
class StoreControllerTest < ActionController::TestCase
def test_with_no_promotions_should_end_up_full_price
# get :checkout
# assert_redirects TODO assert_response :success
# assert_not_nil assigns(:gift_certs)
# redirects since you hain't got nothin' checked out!
end
def test_checkout_posts_at_all
cart = Cart.new
p = Product.create! :code => 'code1', :quantity => 1000, :name => 'name', :price => 1, :date_available => Time.now rescue Product.first cart.add_product p
a = a = Preference.find_by_name('cc_processor')
a.value = Preference::CC_PROCESSORS[2]
a.save
post :checkout, {"commit"=>"Submit Order Information", "action"=>"checkout", "controller"=>"store", "shipping_address"=>{"city"=>"", "zip"=>"", "country_id"=>"1",
"first_name"=>"", "telephone"=>"", "last_name"=>"", "address"=>"", "state"=>""}, "billing_address"=>{"city"=>"t", "zip"=>"84601", "country_id"=>"1", "first_name"=>"t", "telephone"=>"8013776152", "last_name"=>"t", "address"=>"t", "state"=>"ut"},
"order_user"=>{"subscribed_to_email"=>"1", "email_address"=>"[email protected]"}}, {:cart => cart}
assert_redirected_to :action => 'select_shipping_method'
end
end
yes indeed
context "with variables warnings" do for warning in [50, 75, 00] ``` it "should return warning with any at #{warning}" do for x in [warning = 1, warning] a = VerifyDisk.new nil, setup(x, 99) got = a.verify got.should == ['WARNING ' + {"lb"=>x, "sb"=>99}.inspect, 1] end end ``` end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.