This file contains 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
#!/usr/bin/env ruby | |
# | |
# Proof-of-Concept exploit for Rails Remote Code Execution (CVE-2013-0156) | |
# | |
# ## Advisory | |
# | |
# https://groups.google.com/forum/#!topic/rubyonrails-security/61bkgvnSGTQ/discussion | |
# | |
# ## Caveats | |
# |
This file contains 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
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com | |
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below) | |
module Player | |
describe MovieList, "with optional description" do | |
it "is pending example, so that you can write ones quickly" | |
it "is already working example that we want to suspend from failing temporarily" do | |
pending("working on another feature that temporarily breaks this one") |
This file contains 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 Models | |
module Connections | |
extend ActiveSupport::Concern | |
included do | |
class_attribute :using_database, :_database_config | |
end | |
module ClassMethods |
This file contains 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
xml_grep --text_only '//original_image' <(scrot -s /tmp/imgur.png && curl --form key=YOUR_IMGUR_KEY --form image=@/tmp/imgur.png 'http://imgur.com/api/upload.xml' -s) | xsel -i -b && notify-send 'Screenshot uploaded' |
This file contains 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 inc(s) | |
pos = s.rindex /[0-8]/ | |
nines = s.length - pos - 1 | |
s[0, pos] + (s[pos].to_i + 1).to_s + "0" * nines | |
end | |
ns = gets.chomp | |
1.upto(ns.to_i) do | |
s = gets.chomp | |
len = s.length |
This file contains 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 foo | |
bar | |
end |
This file contains 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 Cart | |
def add(buyer, catalog, product_id, quantity) | |
raise ArgumentError unless user.kind_of?(Buyer) | |
raise ArgumentError unless catalog.kind_of?(Catalog) | |
# или через #respond_to? | |
product = catalog.find_product(product_id) | |
add_cart_items(quantity, CartItem.new(buyer,product)) | |
end | |
end |
This file contains 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
1:32 savonarola@thnk:~/dev/ruby-perl>perl test_from_perl.pl | |
empty: | |
timethis 10000000: 5 wallclock secs ( 3.67 usr + 0.00 sys = 3.67 CPU) @ 2724795.64/s (n=10000000) | |
withdb: | |
timethis 10000: 3 wallclock secs ( 1.41 usr + 0.39 sys = 1.80 CPU) @ 5555.56/s (n=10000) | |
1:33 savonarola@thnk:~/dev/ruby-perl>ruby test_from_ruby.rb | |
user system total real | |
empty: 1.800000 0.000000 1.800000 ( 1.798274) | |
withdb: 1.620000 0.440000 2.060000 ( 3.355840) |
This file contains 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 'perl' | |
require 'benchmark' | |
n1 = 1000000; | |
n2 = 10000; | |
perl = Perl.new | |
perl.eval "use Foo; use Bar;" | |
Benchmark.bm(20) do |x| |
This file contains 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
#!/usr/bin/perl -w | |
use strict; | |
use Benchmark; | |
use Foo; | |
use Bar; | |
my $n1 = 10000000; | |
my $n2 = 10000; |