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 / install_ruby_rbenv_sh
Last active October 11, 2015 13:37
Getting Umlauts/UTF-8 in irb or rails/console on the mac using rbenv
RUBY_VERSION="1.9.3-p362"
###Use this for global readline for later reuse
# OPT_DIR=/usr/local/ruby-opt/
OPT_DIR=${HOME}/.rbenv/versions/${RUBY_VERSION}/
git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
cd ~/.rbenv/plugins
git clone git://github.com/sstephenson/ruby-build.git
cd /tmp
@thomaswitt
thomaswitt / get_aws_account_id.rb
Created October 25, 2012 12:26
Find the ARN/AWS Account ID (whoami) for a given credential set via AWS Ruby SDK
require 'aws-sdk'
def get_aws_account_id(access_key_id, secret_access_key)
begin
iam = AWS::IAM.new(:access_key_id => access_key_id,
:secret_access_key => secret_access_key)
iam = iam.client.get_user
id, user = iam[:user][:arn].match('^arn:aws:iam::([0-9]{12}):(.*)$').captures
rescue AWS::IAM::Errors::AccessDenied
result = $!
@thomaswitt
thomaswitt / sms.rb
Created November 3, 2012 09:50
How to send an SMS via Sipgate API and Ruby
require 'xmlrpc/client'
class SMS
def self.deliver(phonenumber, text)
user = Rack::Utils.escape(SIPGATE_USER_NAME)
url = "https://#{user}:#{SIPGATE_PASSWORD}@api.sipgate.net/RPC2"
client = XMLRPC::Client.new2(url)
client.call('samurai.ClientIdentify', {'ClientName' => 'Ruby-Client'} )
number = strip_phonenumber(phonenumber)
@thomaswitt
thomaswitt / bydesign_printer.rb
Created January 10, 2013 16:14
SAP SaaS-Solution Business ByDesign has a Print API, which allows you to spool print jobs to be fetched remotely over the Web. Decoding this API is one of the biggest mess I've ever seen. Anyway, finally I got it right and now I've got a nice ruby printer spooler which you can put in your crontab. It polls the print queue of ByDesign, retrieves …
#!/usr/bin/env ruby
require 'rubygems'
require 'savon'
require 'tempfile'
require 'base64'
USER = 'PRT_001'
PASS = 'YOUR_PASSWORD_GOES_HERE'
SAP_BASE_URL = 'https://my012345.sapbydesign.com'
@thomaswitt
thomaswitt / list_aws_iam_users.rb
Created October 5, 2013 11:23
List all AWS IAM Users of an account
#!/usr/bin/env ruby
require 'rubygems'
require 'aws-sdk'
require 'highline/import'
def get_aws_account_data(iam)
begin
iam = iam.client.get_user
id, user = iam[:user][:arn].match('^arn:aws:iam::([0-9]{12}):(.*)$').captures
@thomaswitt
thomaswitt / rename_pem_certs
Created November 5, 2013 12:23
Rename PEM certificates to CN and date
#!/usr/bin/ruby
require 'openssl'
require 'date'
Dir.chdir('/Users/thomas/Desktop/certs')
Dir.glob('./*.pem') do |file|
next if file =~ /.k.pem$/
puts file
@thomaswitt
thomaswitt / oracle_login.sql
Created November 6, 2013 09:50
Oracle Login File
SET termout OFF
ALTER SESSION SET NLS_DATE_FORMAT = 'dd.mm.yyyy HH24:mi:ss';
SET termout ON
SET sqlprompt "_USER'@'_CONNECT_IDENTIFIER _PRIVILEGE> "
set pagesize 50000
SET linesize 190
@thomaswitt
thomaswitt / omnigraffle_export_all_files.scpt
Created November 6, 2013 10:16
Export all OmniGraffle Canvasses
tell application "OmniGraffle Professional 5"
--Setup export options
set current export settings's area type to selected graphics
set current export settings's draws background to false
set current export settings's export scale to 1
set current export settings's include border to false
set current export settings's resolution to 2.0
--Retrieve the desired output export path
set myFolder to POSIX path of (choose folder)
@thomaswitt
thomaswitt / applescript_string_helper
Created November 6, 2013 10:18
Apple Script String Helpers
on replace(sourcetext, search, replacement)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to the search
set the textItemList to every text item of the sourcetext
set AppleScript's text item delimiters to the replacement
set the output to the textItemList as string
set AppleScript's text item delimiters to oldDelim
return output
end replace
@thomaswitt
thomaswitt / check_oracle.rb
Created November 6, 2013 10:29
Check Oracle One Liner Ruby
ruby -r oci8 -e "OCI8.new('xms01','R1launch','//my.cool.host:1521/ORACM.BLA').exec('select sysdate from dual') do |r| puts r.join(','); end"