Skip to content

Instantly share code, notes, and snippets.

View glaszig's full-sized avatar

glaszig

  • available for hire. contact me.
  • remote
View GitHub Profile
@glaszig
glaszig / mkp2pblocklist
Last active January 30, 2022 00:30
creates a blocklist for your p2p endeavors
#!/usr/bin/env sh
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2020 glaszig <glaszig@gmail.com>
#
# Everyone is permitted to copy and distribute verbatim or modified
# copies of this license document, and changing it is allowed as long
# as the name is changed.
@glaszig
glaszig / if_.patch
Created August 2, 2016 22:11
munin 2.0.19 if plugin patch
--- if_.orig 2016-08-02 23:52:05.691224811 +0200
+++ if_ 2016-08-02 23:52:49.563223127 +0200
@@ -91,7 +91,7 @@
# iwlist first)
if [[ -r /sys/class/net/$INTERFACE/speed ]]; then
SPEED=$(cat /sys/class/net/$INTERFACE/speed 2>/dev/null)
- if [[ -n "$SPEED" ]]; then
+ if [ -n "$SPEED" -a "$SPEED" -gt "0" ]; then
echo $SPEED
return
@glaszig
glaszig / hex_benchmark.rb
Last active June 20, 2016 20:49
ruby hex encode algorithm performance comparison
require 'benchmark'
ITERATIONS=100_000
INPUT='https://www.example.com/path/to/image.png'.freeze
def interpolate
INPUT.to_enum(:each_byte).map{ |byte| "%02x" % byte }.join
end
def unpack
@glaszig
glaszig / rails-vendor-assets.patch
Created June 7, 2016 19:27
example of have a precompiled vendor asset
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 722b3a8..e32d6db 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -4,6 +4,7 @@
<title>AssetsDemo</title>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
+ <%= javascript_include_tag 'jquery.mousewheel', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
@glaszig
glaszig / vcr-webmock-2.rb
Last active January 3, 2020 00:04
converts vcr cassettes to webmock 2.0-compatible format
# converts URIs in vcr cassettes from uri-based basic auth
# to header-based basic auth to be compatible with webmock 2.0.
# it will create a basic auth header with an ERB tag
# to keep user and password be editable.
#
# Authorization: Basic <%= Base64.encode64("user:password").chomp %>
#
# may not work if using VCR's filter_sensitive_data.
# in that case use https://gist.github.com/ujh/594c99385b6cbe92e32b1bbfa8578a45
#
@glaszig
glaszig / application.rb
Created March 10, 2016 11:57
Grouped table index for ActiveAdmin
# config/application.rb
module MyApp
class Application < Rails::Application
config.autoload_paths << config.root.join('lib')
end
end
# mtr -r -w -c 10 rubygems.global.ssl.fastly.net
HOST: ip-172-31-1-177 Loss% Snt Last Avg Best Wrst StDev
1. ec2-54-93-0-2.eu-central-1.compute.amazonaws.com 0.0% 10 0.5 1.0 0.4 1.7 0.5
2. 54.239.5.169 0.0% 10 1.4 1.3 1.3 1.4 0.0
3. 54.239.106.48 0.0% 10 12.3 301.5 3.1 1278. 490.9
4. 54.239.106.31 0.0% 10 1.7 1.4 1.2 1.7 0.1
5. ffm-b10-link.telia.net 0.0% 10 1.3 1.2 1.1 1.3 0.1
6. ??? 100.0 10 0.0 0.0 0.0 0.0 0.0
7. 185.31.17.249 0.0% 10 1.2 1.3 1.2 1.4 0.1
@glaszig
glaszig / fingerprint.sh
Created September 4, 2015 20:40
show ssl fingerprints for remote hosts
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: `basename $0` hostname [hostname]..."
exit $E_NOARGS
fi
until [ -z "$1" ]; do
host=$1
@glaszig
glaszig / passlib_plugin.py
Created August 12, 2015 22:52
ansible passlib filter plugin
# this ansible/jinja2 filter plugin allows you to use passlib's *_crypt functions
# until ansible 2.0 comes out - see https://github.com/ansible/ansible/issues/11244.
#
# this filter depends on passlib being installed:
# $ pip install passlib
#
# put this into your playbook's `filter_plugins` folder.
#
# usage example:
# - name: create user
@glaszig
glaszig / upload.rake
Created July 16, 2014 14:05
Upload task for Capistrano 3
namespace :deploy do
desc "Uploads a comma-separated list of files from ENV['files']"
task :upload do
on roles(:app) do
ENV.fetch('files', ENV['FILES']).split(',').map(&:strip).each do |file|
upload! file, current_path.join(file), recursive: true
end
end
end
end