Skip to content

Instantly share code, notes, and snippets.

View postmodern's full-sized avatar
🚀
releasing new versions

Postmodern postmodern

🚀
releasing new versions
View GitHub Profile
@postmodern
postmodern / gist:963589
Created May 9, 2011 22:51
net-http-server benchmarks (single threaded)
$ ab -n 1000 http://localhost:8080/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@postmodern
postmodern / gist:1020374
Created June 11, 2011 08:44
rbx -Xprofile benchmarks/hexdump.rb
% cumulative self self total
time seconds seconds calls ms/call ms/call name
------------------------------------------------------------
10.98 277.26 104.33 30721151 0.00 0.01 Hash#find_entry
9.58 116.29 91.02 36303266 0.00 0.00 Hash::Entry#match?
9.51 141.50 90.35 29760101 0.00 0.00 String#<<
5.52 501.94 52.41 9920000 0.01 0.05 Hexdump::Dumper::print<330> {}
4.72 949.77 44.83 12 3735.59 79147.48 String#each_byte
4.70 345.50 44.70 9920000 0.00 0.03 Hexdump::Dumper::each<279> {}
4.18 321.67 39.69 30721093 0.00 0.01 Hash#[]
@postmodern
postmodern / gist:1068927
Created July 7, 2011 05:23
half-assed attempt at rewriting dm-gen to use Thor
require 'thor'
require 'thor/actions'
module DataMapper
module Gen
class CLI < Thor
include Thor::Actions
DM_VERSION = '1.0'
@postmodern
postmodern / gist:1071496
Created July 8, 2011 10:01
A bug in Module.methods with Ruby 1.8 and 1.9?
module Test
def Test.mytest
end
end
Test.methods(false)
# => ["mytest"]
Test.method_defined?("mytest")
# => false
@postmodern
postmodern / register.rb
Created July 28, 2011 07:17
Example of what is possible with RSpec2

Install RSpec

$ gem install rspec

Run it!

$ rspec --color --format=d register.rb
CashRegister
  when empty

items

@postmodern
postmodern / gist:1141488
Created August 12, 2011 04:55
Convert Markdown slides (separated by ------------- dividers) into divs for slippy.js
$(function() {
var $slides = $("#slides");
var $currentSlide = null;
function newSlide() {
$currentSlide = $('<div class="slide"></div>')
$currentSlide.appendTo($slides);
}
newSlide();
@postmodern
postmodern / dm_eager_loader.rb
Created October 27, 2011 01:34
Fork of d11wtq's DataMapper EagerLoader plugin
module DataMapper
class Collection
#
# EagerLoader takes a QueryPath object and loads all relationships
# referenced in the path, into an existing Collection.
#
# Using eager-loading allows you to optimize out the classic "n+1"
# query problem, when you intend to iterate over several arbitrarily deeply
# nested relationships. One query per relationship is executed,
# vs one query per record.
@postmodern
postmodern / mysql_brute.rb
Created November 21, 2011 03:39
MySQL Bruteforcer

Configuration

  • mysql: 14.14 Distrib 5.5.14
  • host: 127.0.0.1
  • port: 3306
  • user: victim
  • password: 56789

Install

@postmodern
postmodern / bin_sh.rb
Created November 29, 2011 07:44
Example of using Assemble DSL in ronin-exploits to write Shellcode in Ruby
require 'ronin/code/asm'
require 'ronin/formatting/binary'
program = Ronin::Code.asm(:arch => :x86) do
xor eax, eax
push eax
push 0x68732f2f
push 0x6e69622f
mov esp, ebx
push eax
@postmodern
postmodern / local_shell.rb
Created November 29, 2011 08:10
Example of a Ronin Shellcode payload, written in pure Ruby.
#!/usr/bin/env ronin-payload -f
require 'ronin/payloads/shellcode'
Ronin::Payloads::Shellcode.object do
cache do
self.name = 'local_shell'
self.description = %{
Shellcode that spawns a local /bin/sh shell