Skip to content

Instantly share code, notes, and snippets.

View daniel-illi's full-sized avatar
💭
☕ 💎 🔋

Daniel Illi-Zuberbühler daniel-illi

💭
☕ 💎 🔋
View GitHub Profile
@daniel-illi
daniel-illi / traefik-auth.conf
Created September 16, 2019 12:19 — forked from acundari/traefik-auth.conf
Traefik fail2ban
# /etc/fail2ban/filter.d/traefik-auth.conf
[Definition]
failregex = ^<HOST> \- \S+ \[\] \"(GET|POST|HEAD) .+\" 401 .+$
@daniel-illi
daniel-illi / youtube-dl
Created September 26, 2018 10:04
dockerized youtube-dl runner
#!/bin/sh
docker run --rm -u 1004:1004 -v "$PWD":/data vimagick/youtube-dl $@
#!/bin/bash
# copied from https://askubuntu.com/questions/892076/how-to-selectively-purge-old-kernels-all-at-once/892077#892077
# NAME: rm-kernels-server
# PATH: /usr/local/bin
# DESC: Provide dialog checklist of kernels to remove
# Non-GUI, text based interface for server distro's.
# DATE: Mar 10, 2017. Modified Aug 5, 2017.
@daniel-illi
daniel-illi / README.md
Created October 6, 2017 11:01 — forked from tristanm/README.md
Migrating a Rails project from MySQL to PostgreSQL

Migrating a Rails project from MySQL to PostgreSQL

This brief guide is written from my own experience with migrating a large (~5GB) MySQL database to PostgreSQL for a Rails project.

No warranties, guarantees, support etc. Use at your own risk and, as always, ENSURE YOU MAKE BACKUPS FIRST!

I chose [pgloader][1] because it's extremely fast. YMMV.

  1. Replace mysql2 gem with pg in Gemfile.
  2. Update config/database.yml for PostgreSQL. I used [Rails' template][2] as a starting point.
@daniel-illi
daniel-illi / gitignore2svnignore.sh
Created April 6, 2017 09:39 — forked from iegik/gitignore2svnignore.sh
Oneliner to convert svn:ignore into .gitignore
#!/bin/bash
cat .gitignore | sed 's/^/\.\//g;s/\(.*\)\/\([0-9a-zA-Z\*\?\.]*\)$/svn propedit svn:ignore "\2" \1 /mg' | bash
@daniel-illi
daniel-illi / HOME_.pry-debundle
Last active February 9, 2017 12:54
pry-byebug without Gemfile entry
# vim: syntax=ruby
# Copyright (c) Conrad Irwin <conrad.irwin@gmail.com> -- MIT License
# Source: https://github.com/ConradIrwin/pry-debundle
#
# To install and use this:
#
# 1. Recommended
# Add 'pry' to your Gemfile (in the development group)
# Add 'pry-debundle' to your Gemfile (in the development group)
#
class Object
def ergo(&b)
if block_given?
b.arity == 1 ? yield(self) : instance_eval(&b)
else
self
end
end
end
@daniel-illi
daniel-illi / truncate.sql
Last active November 2, 2016 09:30
Postgres truncate_tables
CREATE OR REPLACE FUNCTION truncate_tables(username IN VARCHAR) RETURNS void AS $$
DECLARE
statements CURSOR FOR
SELECT schemaname, tablename FROM pg_tables
WHERE tableowner = username AND schemaname = 'public';
BEGIN
FOR stmt IN statements LOOP
EXECUTE 'TRUNCATE TABLE ' || quote_ident(stmt.schemaname) || '.' || quote_ident(stmt.tablename) || ' CASCADE;';
END LOOP;
END;
button {
position: absolute;
visibility: hidden;
}
button:before {
content: "goodbye";
visibility: visible;
}
@daniel-illi
daniel-illi / dig.rb
Created June 14, 2016 09:13
ruby dig backport
unless Hash.instance_methods(true).include?(:dig)
class Hash
def dig(*path)
head, *tail = *path
if tail.empty?
self[head]
else
self[head].dig(*tail)
end
end