Skip to content

Instantly share code, notes, and snippets.

View kaspergrubbe's full-sized avatar

Kasper Grubbe kaspergrubbe

View GitHub Profile
<?php
# Insert code here
# Break if a command fails
set -eu
set -o pipefail
# Update system and install essentials
apt-get update
apt-get upgrade
apt-get -y install lsof #debug
apt-get -y install curl
require 'mechanize'
client = Mechanize.new { |agent|
agent.user_agent = "Curl/Ruby"
agent.pluggable_parser.default = Mechanize::Download
}
# Go to login-page and submit
page = client.get('https://login.engineyard.com/login')
login_form = page.forms.select {|f| f.action == 'https://login.engineyard.com/login' }.first
require 'uri'
require 'net/https'
uri = URI.parse("https://staging.billetto.dk:443/en/payments/form")
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 30
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
request = Net::HTTP::Get.new(uri.request_uri)
@kaspergrubbe
kaspergrubbe / setup.rb
Created October 21, 2014 19:33
setup.rb
#!/usr/bin/env ruby
require 'fileutils'
def install_file(target, destination)
target = File.join(File.dirname(__FILE__), target)
destination = File.join(File.expand_path('~'), destination)
puts "Moving file #{target} -> #{destination}"
FileUtils.rm destination if File.file?(destination)
FileUtils.touch destination
require 'uri'
require 'net/https'
uri = URI.parse("https://www.facebook.com")
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 30
http.use_ssl = true
request = Net::HTTP::Get.new(uri.request_uri)
response = http.request(request)
def datetime_step(start_at, end_at)
(start_at.to_i .. end_at.to_i).step(1.hour).each do |date|
Time.at(date)
end
end
def int_step(start_at, end_at)
(start_at.to_i .. end_at.to_i).step(3600).each do |date|
Time.at(date)
end
@kaspergrubbe
kaspergrubbe / bm-4.rb
Created August 11, 2014 20:10 — forked from ujifgc/bm-4.rb
#!/usr/bin/env ruby
require 'benchmark'
PREFIX = %W(TiB GiB MiB KiB B).freeze
UNITS = %W(B KiB MiB GiB TiB).freeze
def as_size1( s )
s = s.to_f
i = PREFIX.length - 1
curl -X POST "https://login.txty.dk/api/4/user/newapikey/login.json?user=hej&pass=davs&description=yourmomma"
200 OK:
{
"status": "error",
"error": "USER_NOT_FOUND",
"login": {
"user": "hej",
"pass": "davs"
}
<?php
$email = "test@hej.dk";
$name = "Kasper";
$surname = "Grubbe";
$postal = "2300";
$city = "hej'); DROP TABLE implevent_subscribers; --";
$sql = "INSERT INTO implevent_subscribers (email, name, surname, postal, city)
VALUES ('$email', '$name', '$surname', '$postal', '$city')";