Skip to content

Instantly share code, notes, and snippets.

Avatar
🚀

Thomas Hollstegge Tho85

🚀
View GitHub Profile
View gist:8732473
javascript:var date=window.prompt('Datum');$('#reiseForm\\:journeyStartDateInput').val(date);$('#reiseForm\\:journeyEndDateInput').val(date);$('#reiseForm\\:journeyTitle').val("Kundenbesuch Fuchs Gewürze GmbH");
View gist:0d3b86ec5bf8d75a8fb2
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")
View gist:e258ac127d8d7f9647aa
require "redis"
client = Redis.new
# Basisfunktionen eines Key-Value Stores:
client.set("my_key", "my_value")
=> "OK"
client.get("my_key")
=> "my_value"
View all_utf8_chars_in_file.rb
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
libvncclient-ruby-test
View Gemfile
gem 'libvncclient-ruby', :require => 'libvnc', :git => 'git@github.com:zweitag/libvncclient-ruby.git'
View fill.rb
def fill(&block)
block.call.gsub(/:(\w+)/) { |match| block.binding.eval "(local_variables.include? :#{$1}) ? #{$1} : raise" rescue match }
end
foo = "Hello"
bar = "World"
fill { ":foo :bar :system :exit!" }
# => "Hello world :system :exit!"
View Markdown.Converter.js
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.
View json_parse.rb
require 'json'
require 'json/generic_object'
JSON.parse '{"json_class":"JSON::GenericObject", "foo":"bar"}'
# => #<JSON::GenericObject foo="bar">
View deploy.rb
# 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
View test.rb
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"