Skip to content

Instantly share code, notes, and snippets.

View mika's full-sized avatar

Michael Prokop mika

View GitHub Profile
@mika
mika / zshrc.local
Created August 21, 2019 12:42
grml-zshrc with custom vcs_info
## customize vcs_info
zstyle ':vcs_info:git*:*' check-for-changes true
zstyle ':vcs_info:git*:*' unstagedstr '|U'
zstyle ':vcs_info:git*:*' stagedstr '|≠'
# enable hooks, requires Zsh >=4.3.11
if [[ $ZSH_VERSION == 4.3.<11->* || $ZSH_VERSION == 4.<4->* || $ZSH_VERSION == <5->* ]] ; then
# hook for untracked files
+vi-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2>/dev/null) == 'true' ]] && \
@mika
mika / jenkins-job-builders.org
Created March 25, 2013 13:34
Jenkins Job creators + editors
@mika
mika / psql_internals_cheatsheet.sql
Created June 15, 2019 10:19 — forked from azet/psql_internals_cheatsheet.sql
PostgreSQL internals SQL collection
# long running queries:
SELECT
pid,
now() - pg_stat_activity.query_start AS duration,
query,
state
FROM pg_stat_activity
WHERE (now() - pg_stat_activity.query_start) > interval '5 minutes';
## active queries and killing them:
@mika
mika / diskchecker.pl
Created May 14, 2019 08:00 — forked from bradfitz/diskchecker.pl
diskchecker.pl
#!/usr/bin/perl
#
# Brad's el-ghetto do-our-storage-stacks-lie?-script
#
sub usage {
die <<'END';
Usage: diskchecker.pl -s <server[:port]> verify <file>
diskchecker.pl -s <server[:port]> create <file> <size_in_MB>
diskchecker.pl -l [port]
@mika
mika / 99-disable-wireless-when-wired
Created April 12, 2019 15:02 — forked from cengiz-io/99-disable-wireless-when-wired
Script should be placed under `/etc/NetworkManager/dispatcher.d/` with a name like `99-disable-wireless-when-wired`. Make sure 1) root owns it 2) it's mod is 755
#!/bin/sh
IFACE=$1
ACTION=$2
ntfy () {
sudo -u cengiz \
DISPLAY=:0 \
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus \
notify-send "$1" "$2"
@mika
mika / rubygem_mirror.sh
Last active December 18, 2018 05:42
generate a (partial) rubygems mirror
## Purpose: create a partial Rubygems mirror on Debian (7 AKA wheezy)
## Design goal: no system wide gems other than Debian packages
# make sure bundler, ruby-builder (required for generate_index) + rubygems-integration (required for gem<->builder integration) are available:
% sudo apt-get install ruby-bundler ruby-builder rubygems-integration
# We use gem-mirror (http://rubygems.org/gems/gem-mirror / https://github.com/YorickPeterse/gem-mirror), so
# install gem-mirror gem itself (requires ruby >=1.9) in local directory for execution via bundler:
% cat Gemfile
source 'https://rubygems.org/'
@mika
mika / upgrade.sh
Created October 19, 2018 15:56 — forked from zeha/upgrade.sh
#!/bin/bash
set -x
puppet agent --disable "update Debian"
service keepalived stop
apt-get install udev acl
sed -i'' -e 's/jessie/stretch/g' /etc/apt/sources.list.d/*
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
apt-get update
apt-get install apt dpkg deborphan # openjdk-8-jre-headless
@mika
mika / how-to-upgrade-nvmw-ssd-firmware-on-linux.md
Created October 8, 2018 06:16 — forked from klingtnet/how-to-upgrade-nvmw-ssd-firmware-on-linux.md
How to upgrade [Lenovo] NVMe SSD firmware on Linux

The instructions were tested on a Lenovo X1 Carbon 5th Gen (X1C5) on Arch Linux but should be applicable to other Lenovo models and Linux distributions.

BACKUP YOUR DATA! I created a bootable Ubuntu Image like this:

$ sudo sh -c 'curl --location --silent --fail "http://releases.ubuntu.com/18.04/ubuntu-18.04.1-desktop-amd64.iso" | pv > /dev/<your-usb-drive>'
# note that pv is only there to show progress, it is perfectly fine to redirect curl to the usb drive directly.

then I booted from this drive by pressing F12 on reboot and dumped my NVMe disk to an external hard drive like this:

@mika
mika / debian-stretch-ami.py
Created August 16, 2018 22:55
Identify latest Debian stretch EC2 AMI in eu-west-1
#!/usr/bin/env python
from bs4 import BeautifulSoup
import urllib2
page = urllib2.urlopen("https://wiki.debian.org/Cloud/AmazonEC2Image/Stretch")
soup = BeautifulSoup(page, features="html.parser")
region = soup.find(text="eu-west-1")
ami = region.find_next().get_text().strip()
print(ami)