Skip to content

Instantly share code, notes, and snippets.

View vonNiklasson's full-sized avatar

Johan Niklasson vonNiklasson

View GitHub Profile
@vonNiklasson
vonNiklasson / remove_old_gcloud_versions.sh
Last active January 16, 2024 16:04
Remove old Google App Engine versions
#!/bin/bash
# A bash script to remove old versions of a Google App Engine instance.
#
# Inspiration of script taken from:
# https://almcc.me/blog/2017/05/04/removing-older-versions-on-google-app-engine/
# Original code by Alastair McClelland and Marty Číž.
# Assembled and modified by Johan Niklasson.
#
# To run this script, execute
@vonNiklasson
vonNiklasson / merge.js
Created November 29, 2017 12:11
Merge Javascript objects recursively
function merge(obj1, obj2) {
var isAnyType = function(obj) { return (typeof obj !== "undefined" ); }
var isSingleType = function(obj) { return (typeof obj === "string" || typeof obj === "number"); }
var isObjectType = function(obj) { return (typeof obj === "object" && !isArrayType(obj)); }
var isArrayType = function(obj) { return Array.isArray(obj); }
if (isAnyType(obj1) && !isAnyType(obj2)) {
return obj1;
}
@vonNiklasson
vonNiklasson / sublime3-disable-zoom.sh
Last active March 7, 2022 13:44
Disable scroll zoom in Sublime 3, by Hugh Perkins from https://superuser.com/a/1121238
cat <<EOF>~/.config/sublime-text-3/Packages/User/"Default (Linux).sublime-mousemap"
[
// Change font size with ctrl+scroll wheel
{ "button": "scroll_down", "modifiers": ["ctrl"], "command": "null" },
{ "button": "scroll_up", "modifiers": ["ctrl"], "command": "null" }
]
EOF
@vonNiklasson
vonNiklasson / Permanent fail2ban.sh
Last active August 23, 2017 15:06
Add permanent ban mode to fail2ban
# Script assembled by Johan Niklasson
#
# Author of the actual content
# Phil Hagen <phil@identityvector.com>
# Instructions from
# http://stuffphilwrites.com/2013/03/permanently-ban-repeat-offenders-fail2ban/
#
# Run and install from web:
# wget -O - https://gist.githubusercontent.com/vonNiklasson/8568c2162c85c546f1b1faef726d5647/raw/ | bash
@vonNiklasson
vonNiklasson / xps_ubntu_hdmi_fix.sh
Last active August 10, 2017 17:54
Fixes the HDMI-problem on Dell XPS 13 when running Ubuntu with the Display Adapter
# Change 4.10.0 to the appropriate version.
# This snippet is modified to work for 4.10.0
# Taken from:
# https://bugs.freedesktop.org/show_bug.cgi?id=93578#c142
sudo -i
apt-get install linux-source-4.10.0
cd /usr/src
tar -jxf linux-source-4.10.0.tar.bz2
cp -R ./linux-source-4.10.0/drivers/gpu/drm/i915 ./i915-usbc
@vonNiklasson
vonNiklasson / translate.py
Last active January 11, 2019 00:22
Management script for Django to easily run the 'makemessages'-command for all files in your Django application.
'''
translate.py
Management script for Django to easily run the
'makemessages'-command for all files in your Django application.
Put in any registered django app in the location
<app>/management/commands/translate.py
and then use
python manage.py translate
to run makemessages on all files in your project