Skip to content

Instantly share code, notes, and snippets.

View databus23's full-sized avatar

Fabian Ruff databus23

View GitHub Profile
@databus23
databus23 / test.rb
Created May 23, 2011 16:41
nokogiri duplicate xpath results bug
require 'rubygems'
require 'nokogiri'
while true
doc=Nokogiri::XML(open('test.xml'))
xpath_query="//MetricTemplate[@name=\"Availability\" or @name=\"does not exist\"]"
puts "xpath: #{xpath_query}"
result = doc.xpath(xpath_query)
if result.length>1
puts "duplicate:"
@databus23
databus23 / gist:1689076
Created January 27, 2012 14:38
Monkey patch Chef::REST::AuthCredentials to support keys directly
#Chef::REST::AuthCredentials accepts only filenames by default
#this extends the Chef::REST::AuthCredentials so that the key can be provided directly
require 'chef/rest/auth_credentials'
class Chef
class REST
class AuthCredentials
alias :original_load_signing_key :load_signing_key
def load_signing_key
if key_file.start_with?("-----BEGIN RSA PRIVATE KEY-----")
@databus23
databus23 / gist:4428531
Created January 1, 2013 16:48
convert xbmc xml nfos to imdb link nfos for rebuilding the video library from scratch
sed -i -n -e 's/\s*<id>\(.*\)<\/id>/http:\/\/www.imdb.com\/title\/\1\//p' *.nfo
@databus23
databus23 / gist:4715855
Last active December 12, 2015 04:38
The gem archive-tar-minitar can't unpack tars with paths that contain more then 100 characters. (This shell command where executed on OSX)
$ touch a_very_very_very_very_very_very_very_very_very_very_very_very_long_filename_longer_then_100_characters.rb
$ tar -cf test.tar a_very_very_very_very_very_very_very_very_very_very_very_very_long_filename_longer_then_100_characters.rb
$ ruby -r archive/tar/minitar -e 'Archive::Tar::Minitar.unpack("test.tar","output/")'
$ ls output/
PaxHeader
a_very_very_very_very_very_very_very_very_very_very_very_very_long_filename_longer_then_100_charact
{
"provisioners": [
{
"type": "shell",
"execute_command": "echo 'vagrant'|sudo -S sh '{{.Path}}'",
"override": {
"virtualbox": {
"scripts": [
"scripts/cleanup.sh",
"scripts/zerodisk.sh"
@databus23
databus23 / stdout.txt
Created November 18, 2013 17:22
IO.read fails to return complete file content on windows ruby 1.9.3p448
IO.read length: 1778
IO.binread length: 2395
next character after read_string: "\x1A"
context after read_string: "TI\"\x0FC:\\Windows\x06;\x00TI\"\x1Awindows_tracing_fla"
test.rb:60:in `load': marshal data too short (ArgumentError)
from test.rb:60:in `<main>'
@databus23
databus23 / ohai6_plugins_benchmark.rb
Last active August 29, 2015 13:58
benchmark ohai plugins
#!/usr/bin/env ruby
require 'optparse'
require 'benchmark'
require 'ohai'
options = {}
rest = OptionParser.new do |opts|
opts.on("-d", "--disabled-plugins [PLUGIN_NAMES]", "Disable ohai plugins by name") do |plugin_names|
Ohai::Config[:disabled_plugins] = plugin_names.split(/\s*,\s*/)
end
@databus23
databus23 / crash.log
Created July 4, 2014 14:21
fish 2.1.0 crashreport
Process: fish [5422]
Path: /usr/local/Cellar/fish/2.1.0/bin/fish
Identifier: fish
Version: 0
Code Type: X86-64 (Native)
Parent Process: ??? [5421]
Responsible: iTerm [752]
User ID: 1529548076
Date/Time: 2014-07-04 10:06:05.440 +0200
@databus23
databus23 / keybase.md
Last active August 29, 2022 07:54
keybase.md

Keybase proof

I hereby claim:

  • I am databus23 on github.
  • I am databus23 (https://keybase.io/databus23) on keybase.
  • I have a public key ASB56IZrECrJBmtnMUgRWtVIqou5e-ZmloqYA-U81Vk9kwo

To claim this, I am signing this object:

@databus23
databus23 / exception
Created February 3, 2016 10:32
rabbitmq stomp exception
=ERROR REPORT==== 3-Feb-2016::10:31:00 ===
** Generic server <0.582.70> terminating
** Last message in was {'EXIT',<0.574.70>,
{function_clause,
[{rabbit_stomp_reader,log_reason,
[{stomp_unexpected_cast,client_timeout},
{reader_state,#Port<0.430455>,
"10.9.22.136:59381 -> 10.67.74.133:61613",
{resume,#Fun<rabbit_stomp_frame.0.116712418>},
{proc_state,"session-Z9Za9c-pnw87cB_XDfA7VA",