Skip to content

Instantly share code, notes, and snippets.

View mfn's full-sized avatar

Markus Podar mfn

View GitHub Profile
@mfn
mfn / find-empty-dir-in-svn.rb
Created March 3, 2011 00:02
Find all empty directories in an svn checkout
require 'find'
dir_to_scan = '.'
dir_to_scan = ARGV[0] if ARGV.count == 1
dirs = []
# First collect all directories, but ignore anything with .svn in it
Find.find( dir_to_scan ) do |entry|
next if entry =~ /\.svn/
require 'find'
dirs_to_scan = [ '.' ]
dirs_to_scan = ARGV if ARGV.length > 0
dirs_to_scan.each do |dir|
Find.find( dir ) do |entry|
if FileTest.directory?(entry) && FileTest.directory?(entry + "/.svn")
puts entry
Find.prune
@mfn
mfn / uri_hash.rb
Created May 21, 2011 20:18
Have an uri give me a hash with all it's components
require 'uri'
require 'pp'
uri = URI.parse "http://foo/bar?baz&frob#blamp"
pp uri.component.each_with_object({}).find_all { |c,h| h[c] = uri.send(c) }
@mfn
mfn / http_responsetime_detailed.rb
Last active December 12, 2015 08:49 — forked from anonymous/http_responsetime_detailed.rb
Munin script written in Ruby to get more details about a single HTTP connection, namely: DNS lookup time, connect time, send request time, wait for first byte of response and response time.
#!/usr/bin/env ruby
require 'uri'
require 'socket'
if ARGV[0] and ( ARGV[0] == "-h" or ARGV[0] == "--help" )
puts "#{$0} [-h|--help] [config]"
puts "Munin plugin to measure individual HTTP timings"
puts " --help,-h Show this help"
puts " config Prints the configuration for munin"
@mfn
mfn / netsniff.js
Last active October 30, 2018 13:18
netsniff.js from phantomjs, added DOMContentLoaded
if (!Date.prototype.toISOString) {
Date.prototype.toISOString = function () {
function pad(n) { return n < 10 ? '0' + n : n; }
function ms(n) { return n < 10 ? '00'+ n : n < 100 ? '0' + n : n }
return this.getFullYear() + '-' +
pad(this.getMonth() + 1) + '-' +
pad(this.getDate()) + 'T' +
pad(this.getHours()) + ':' +
pad(this.getMinutes()) + ':' +
pad(this.getSeconds()) + '.' +
@mfn
mfn / README.md
Last active April 7, 2022 20:05
Generated munin graph from HAR file

Parses a HAR archive (e.g. generated with https://gist.github.com/mfn/5111680 ) and generate three type of graphs: hosts, mimetypes and timings.

Requires environment variables to be used:

  • HAR pointing to the HAR file
  • SECTION to choose between HOSTS, MIMETYPES and TIMINGS
  • GRAPH_CATEGORY,
  • GRAPH_TITLE

To use the plugin usually requires creating a symlink for each graph type you want and configuring them via plugin-conf.d/.

@mfn
mfn / Elite_Matrix.icls
Last active October 2, 2020 09:39
PhpStorm Elite Matrix editor color scheme
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="Elite_Matrix" version="124" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="14" />
<option name="CONSOLE_FONT_NAME" value="Monospaced" />
<option name="CONSOLE_FONT_SIZE" value="12" />
<option name="EDITOR_FONT_NAME" value="Consolas" />
<colors>
<option name="CARET_COLOR" value="db33" />
<option name="CARET_ROW_COLOR" value="90" />
@mfn
mfn / redis.diff
Created September 30, 2013 19:02
Primitive patch against logstash 1.2.1 to fight utf-8 encoding problems from logfiles you can't control
diff --git a/lib/logstash/outputs/redis.rb b/lib/logstash/outputs/redis.rb
index 7aab4f2..cb5c4aa 100644
--- a/lib/logstash/outputs/redis.rb
+++ b/lib/logstash/outputs/redis.rb
@@ -148,10 +148,11 @@ class LogStash::Outputs::Redis < LogStash::Outputs::Base
# if they fail to convert properly.
begin
payload = event.to_json
- rescue Encoding::UndefinedConversionError, ArgumentError
+ rescue Exception => e
@mfn
mfn / indent.js
Last active August 29, 2015 14:06 — forked from catearcher/indent.js
(function() {
var someVariable = {
foo: 42
},
someString = 'Well hello there.',
someOtherVariable = {
isThisVeryConfusing: true
},
// okay, please imagine 200 more lines of more declarations here
@mfn
mfn / indent.js
Last active August 29, 2015 14:06 — forked from catearcher/indent.js
(function() {
var
someVariable = {
foo: 42
},
someString = 'Well hello there.',
someOtherVariable = {
isThisVeryConfusing: true
},