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 / gist:10606804
Last active August 29, 2015 13:59
t.co fuck-up
$ curl -i http://t.co/OKqKyWmofP
HTTP/1.1 404 Not Found
Date: Sun, 13 Apr 2014 23:39:33 GMT
Server: Apache/2.2.15 (CentOS)
X-Powered-By: PHP/5.3.3
Content-Length: 268
Connection: close
Content-Type: text/html; charset=UTF-8
<head><noscript><meta http-equiv="refresh" content="0;url=http://fernsehkritik.tv/folge-134/Start/"></noscript><script type="text/javascript">window.location = "http://18tdn.com/r.php?r=http%3A%2F%2Ffernsehkritik.tv%2Ffolge-134%2FStart%2F&ase=d47c5f40"</script></head>
@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
@glaszig
glaszig / ABOUT
Created October 7, 2012 12:23 — forked from ngabel/ABOUT
A custom class that lets you use property accessor syntax to set/get member vars. (Works very much like NSManagedObject)
If you use this code it would be great to receive a credit and link back in your app! Thanks.
-Niels Gabel
PlacePop Inc
http://placepop.com
http://nielsbot.com
# 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 / 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 / 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 / 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
#!/usr/bin/env sh
set -e
HOME_DIR="/home/git"
WWW_DIR="/usr/local/www/gitweb"
REPOS_PATH="$HOME_DIR/repositories"
GITWEB_CONF="/etc/gitweb.conf"
GITWEB_PATH="/usr/local/share/examples/git/gitweb"
BANNER="# created by bootstrap script. manual changes might get lost."
@glaszig
glaszig / test_helper.rb
Created October 15, 2018 19:43
Method to set value of range input field with Capybara
class ActionDispatch::IntegrationTest
# usage: set_range "My Range Field", to: 42
# this also triggers the input's change and/or input events
# as opposed to find_field("My Range Field").set 42
def set_range(locator = nil, to:, **find_options)
find_field(locator, find_options).execute_script %Q(this.value = "#{to}")
end
end
@glaszig
glaszig / regexp_escape.py
Created October 21, 2018 01:17
Jinja plugin (for use with Ansible) to run re.escape against input
# (c) 2018, glaszig@gmail.com
#
# This is free software: you can redistribute it and/or modify
# it under the terms of the MIT license.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MIT License for more details.
#