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
<?php | |
# Insert code here |
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
# 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 |
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 '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 |
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 '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) |
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 | |
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 |
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 '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) |
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 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 |
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 | |
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 |
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
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" | |
} |
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
<?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')"; |