Skip to content

Instantly share code, notes, and snippets.

View thomaswitt's full-sized avatar
💭
Investing pre-seed/seed into tech startups via @ExpediteVentures

Thomas Witt thomaswitt

💭
Investing pre-seed/seed into tech startups via @ExpediteVentures
View GitHub Profile
@thomaswitt
thomaswitt / get_aws_eu_ip_ranges.sh
Last active October 21, 2016 13:28
Get IP ranges of AWS in Europe
curl -s https://ip-ranges.amazonaws.com/ip-ranges.json | jq -r '.prefixes[] | select(.region=="eu-west-1" or .region == "eu-central-1" or .region == "GLOBAL") | .ip_prefix' | sort -u | sort -n
@thomaswitt
thomaswitt / test_api_ssl_endpoints.rb
Created March 11, 2015 14:32
test_api_ssl_endpoints.rb
#!/usr/bin/env ruby
require 'openssl'
require 'socket'
require 'uri'
CA_BUNDLE_URL='https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt'
#CA_BUNDLE_URL='https://raw.githubusercontent.com/bagder/ca-bundle/e9175fec5d0c4d42de24ed6d84a06d504d5e5a09/ca-bundle.crt'
puts "Downloading ca-bundle.crt from github to local file"
@thomaswitt
thomaswitt / VPN_FritzBox_OnDemand.mobileconfig
Last active March 17, 2022 12:23
iOS VPN configuration file: Connect to FritzBox VPN if connected to the internet through any insecure WiFi Network (all except than trusted) … customize all strings starting with REPLACE_
Check out the newer version of this gist at:
https://gist.github.com/thomaswitt/2f847199863a103dfcf004fec3c538d0
and the corresponding blog post:
https://thomas-witt.com/auto-connect-your-ios-device-to-a-vpn-when-joining-an-unknown-wifi-d1df8100c4ba
# upload-cert www_myserver_com.crt aws_profile_name SSL123_SecondaryCA.crt SSL123_PrimaryCA.crt
function upload-cert() {
NAME=`echo "$1" | cut -d'.' -f1`
END=`openssl x509 -in $NAME.crt -noout -enddate | cut -f2 -d= | while read x; do date -j -f '%b %d %T %Y %Z' "$x" '+%Y-%m-%d'; done`
cat $3 $4 $5 >certchain.pem
aws --profile $2 iam upload-server-certificate --server-certificate-name ${NAME}-${END} \
--certificate-body file://$NAME.crt --private-key file://$NAME.key.rsa --certificate-chain file://certchain.pem
}
@thomaswitt
thomaswitt / create_route53_domains.rb
Last active August 29, 2015 13:57
Mass Create Route 53 Domains at AWS
require 'aws-sdk'
AWS.config({
access_key_id: ENV['AWSAccessKeyId'].strip,
secret_access_key: ENV['AWSSecretKey'].strip,
region: 'eu-west-1',
use_ssl: true,
})
r53 = AWS::Route53.new
@thomaswitt
thomaswitt / crawl_sipgate.rb
Last active August 29, 2015 13:56
As the sipgate guys appearently don't have an API to fetch all users and SIP credentials for provisioning, you have to crawl their web-site. Ugly, but it works. The crawl may take quite some time, so you're better off caching it. If there's somebody listening from @sipgate: please provide a clean API …
require 'mechanize'
m = Mechanize.new
users = []
rooms = []
login = m.get('https://secure.live.sipgate.de/settings/setup')
login.form do |f|
f.username = 'name@company.com'
f.password = 'secret_password'
@thomaswitt
thomaswitt / get_pingdom_probe_servers.sh
Created February 11, 2014 09:33
Get all pingdom probe servers by IP, useful for adding to an EC2 security group
wget -q -O - \
https://www.pingdom.com/rss/probe_servers.xml | \
perl -nle 'print $1 if /IP: (([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5])\.([01]?\d\d?|2[0-4]\d|25[0-5]));/' | \
sort -n -t . -k1,1 -k2,2 -k3,3 -k4,4
@thomaswitt
thomaswitt / deploy_to_opsworks.rake
Last active April 25, 2016 02:59
Deploy to opsworks via rake
# Put this into lib/tasks
require 'rubygems'
require 'bundler'
require 'aws-sdk'
require 'socket'
require 'os'
if Rails.env.development?
@thomaswitt
thomaswitt / crypt_helper.rb
Last active January 4, 2016 06:09
Crypt Helper
require 'rubygems'
require 'openssl'
require 'digest/sha2'
require 'base64'
class CryptHelper
def self.generate_rsa_key(passphrase, bits = 4096)
cipher = OpenSSL::Cipher::AES256.new(:CBC)
rsa_key = OpenSSL::PKey::RSA.generate(bits)
@thomaswitt
thomaswitt / meraki_controller.rb
Last active January 4, 2016 02:29
Rails Controller for the Meraki Presence API. You need to generate a models for saving these into the database via: rails generate model presence ap_mac:string client_mac:string last_seen:datetime rssi:integer
# 1. Generate a model Presence before:
# rails generate model presence ap_mac:string client_mac:string last_seen:datetime rssi:integer
#
# 2. Add a route:
# match 'meraki', :to => 'meraki#presenceapi', :as => :meraki
#
# 3. Test this controller via:
# curl -d data="{\"secret\":\"foobar\",\"probing\":[{\"ap_mac\":\"00:aa:bb:cc:dd:ee\",\"client_mac\":\"ff:ee:dd:cc:bb:aa\",\"last_seen\":\"Wed Jan 22 08:34:02.409 UTC 2014\",\"rssi\":\"16\"},{\"ap_mac\":\"11:22:33:44:55:66\",\"client_mac\":\"99:88:77:66:55:44\",\"last_seen\":\"Wed Jan 22 08:34:06.409 UTC 2014\",\"rssi\":\"29\"}]}" https://localhost:3000/meraki
#
# 4. Point Meraki to https://my.app.name/presenceapi