Skip to content

Instantly share code, notes, and snippets.

View Tho85's full-sized avatar
🚀

Thomas Hollstegge Tho85

🚀
View GitHub Profile
require "set"
def all_chars_in_file(file)
all_chars = Set.new
File.open(file).each_line do |line|
line.chars.inject(all_chars) { |s,c| s << c }
end
all_chars
end
@Tho85
Tho85 / Gemfile
Created May 20, 2011 08:40
libvncclient-ruby-test
gem 'libvncclient-ruby', :require => 'libvnc', :git => 'git@github.com:zweitag/libvncclient-ruby.git'
var Markdown;
if (typeof exports === "object" && typeof require === "function") // we're in a CommonJS (e.g. Node.js) module
Markdown = exports;
else
Markdown = {};
// The following text is included for historical reasons, but should
// be taken with a pinch of salt; it's not all true anymore.
require 'json'
require 'json/generic_object'
JSON.parse '{"json_class":"JSON::GenericObject", "foo":"bar"}'
# => #<JSON::GenericObject foo="bar">
# Start SSH session on first available server
task :ssh do
hostname = find_servers_for_task(current_task).first
exec %Q|ssh -l #{user} #{hostname} -t '#{default_shell}'|
end
# Start Rails console on first available server
namespace :rails do
task :console, :roles => :app do
hostname = find_servers_for_task(current_task).first

Build your own private, encrypted, open-source Dropbox-esque sync folder

Prerequisites:

  • One or more clients running a UNIX-like OS. Examples are given for Ubuntu 12.04 LTS, although all software components are available for other platforms as well (e.g. OS X). YMMV
  • A cheap Ubuntu 12.04 VPS with storage. I recommend Backupsy, they offer 250GB storage for $5/month. Ask Google for coupon codes.

Software components used:

  • Unison for file synchronization
  • EncFS for folder encryption
require 'pry'
class FooBar
def hello
puts "world!"
end
end
puts Pry::WrappedModule.new(FooBar).source
# => "class FooBar\n def hello\n puts \"world!\"\n end\nend\n"
From dfa54b947815fdf1ba957c64bb4e489d041bbf3e Mon Sep 17 00:00:00 2001
From: Thomas Hollstegge <thomas.hollstegge@gmail.com>
Date: Mon, 2 Sep 2013 18:07:47 +0200
Subject: [PATCH 1/2] Check all CNs when testing for domain name
---
lib/ssltool/certificate.rb | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/ssltool/certificate.rb b/lib/ssltool/certificate.rb
@Tho85
Tho85 / .zshrc
Last active December 28, 2015 07:59
# Activate vim mode
bindkey -v
bindkey "^e" emacs-editing-mode
# Map history backward search (Ctrl-R in emacs mode) to [command-mode]?
bindkey -M vicmd '?' history-incremental-search-backward
# Present a nice prompt
vim_ins_mode="%{%F{white}%}⎆"
vim_cmd_mode="%{%F{red}%}⌘"
wireshark-on () {
SERVER=$1
shift
if [ $# -gt 0 ]
then
FILTER="$@"
else
FILTER="not tcp port ssh"
fi
wireshark -k -i <(ssh $SERVER $WIRESHARK_SUDO tcpdump -i any -s 0 -w - "$FILTER")