Skip to content

Instantly share code, notes, and snippets.

View andreas-marschke's full-sized avatar
🏠
Open Source Saves Lives! <3

Andreas Marschke andreas-marschke

🏠
Open Source Saves Lives! <3
View GitHub Profile
@andreas-marschke
andreas-marschke / b.js
Created October 31, 2014 20:51
b.js - Boomerang Setup in around 500 bytes
/* b.js - Boomerang Setup in around 500 bytes
* ------------------------------------------
* Complete boomerang.js initialization with essential plugins in around 500 bytes
* It mimics "Google Analytics"-style script injection using document.createElement
* and document.head.appendChild().
*
* Beacon URL configuration + configuring Plugins as a variable to the beacon:
*
* http://boomerang.example.org/beacon/0000/dashboard/start?plugins=BW%7CRT%7Cnavtimin%7Crestiming&...
*
@andreas-marschke
andreas-marschke / index.html
Created December 26, 2012 10:00
Example script for using Rickshaw graphing with backbone.js
<!doctype html>
<html>
<head>
<link href="https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.css">
</head>
<body>
<div id="graph"></div>
<div id="legend"></div>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="http://underscorejs.org/underscore-min.js"></script>
@andreas-marschke
andreas-marschke / gist:4751200
Last active December 12, 2015 09:28
When you have a set of collapsibles inside a modal events from inside like "shown" are bubbling up. So unless you make sure it's only the modal you are listening to, the callback will fire anyway. Better make sure it only happens once.
$("#modal").modal({
show: true,
backdrop: true,
keyboard: true
}).on("shown",function(e) {
/* suppress 'shown' events bubbling up from inside */
if ($(e.target).hasClass('modal')){
/*do something*/
}
});
perl -Mojo -E 'say g("http://www.jargon.net/")->dom->at("font")->all_text'
@andreas-marschke
andreas-marschke / minify.pm
Last active December 17, 2015 16:49
Mojolicious Command to minify all CSS/JS Scripts in a directory and save minified versions as .min.{js|css}
package Mojolicious::Command::minify;
use Mojo::Base 'Mojolicious::Commands';
use File::Find;
use File::Slurp;
has description => "Minify scripts in public/ directory.\n";
has hint => <<"EOF";
Minifies all Javascript and CSS files with the .js instead of the .min.js extension.
EOF
@andreas-marschke
andreas-marschke / gist:5912142
Created July 2, 2013 19:09
Visualize Nagios Configuration using GraphViz and Perl Usage: recursive copy your /etc/nagios or /etc/icinga to a box of your choosing. Make sure : - GraphViz2, - Nagios::Object::Config, - String::Random from CPAN are installed. From within your copy of the nagios configuration run: perl script.pl -n nagios.cfg -o output.svg Be *amazed* by the s…
#!/usr/bin/perl
=head1 NAME
nagios-view - View config of nagios in SVG/PNG
=head1 SYNOPSIS
nagios-view --nagioscfg nagios.cfg --output nagios-config-visualized.svg
@andreas-marschke
andreas-marschke / run.sh
Created December 17, 2014 22:21
Small example LUA script for wg/wrk using a tiny JSON implementation(http://regex.info/blog/lua/json) to log test results to a file.
# Example usage with several configuration sets as in multiple connections durations and threads.
# You may go take the rest of the day off while this will run ;)
for duration in 10s 1m 10m 1h
do
for connections in 100 200 300 400 500 600
do
for thread in 1 2 3 4 5
do
wrk -d$duration -c$connections -t$thread -s wrk-script.lua http://localhost:4001/beacon/0001/demo-load-test/test/web