Skip to content

Instantly share code, notes, and snippets.

View matthiasbeyer's full-sized avatar

Matthias Beyer matthiasbeyer

View GitHub Profile
@matthiasbeyer
matthiasbeyer / Makefile
Created January 8, 2016 11:50
codelistings error with pandoc-crossref
#
#
#
# Variables
#
#
#
DOCUMENT_CLASS=article
SETTING_FONTSIZE=11pt
@matthiasbeyer
matthiasbeyer / mass-update.sh
Created April 12, 2016 10:37
nix package update apply helper
#!/usr/bin/env bash
EXEC=$(dirname ${BASH_SOURCE[0]})/nixpkgs-update-pkg.sh
if [[ ! -e $1 ]]; then
echo "Does not exist: $1"
echo "Exit."
exit 1
fi
[ 2.142954] List of all partitions:
[ 2.143444] No filesystem could mount root, tried:
[ 2.144192] Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
[ 2.144247] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.8.0-rc8 #1
[ 2.144247] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.7.5-20140531_083030-gandalf 04/01/2014
[ 2.144247] 0000000000000000 ffffffff812f00af ffffffffffffff00 ffff88000750fea8
[ 2.144247] ffffffff8115c4d0 0000000000000010 ffff88000750feb8 ffff88000750fe50
[ 2.144247] ffff88000750fea8 ffff88000750fec0 0000000000000012 0000000000000001
[ 2.144247] Call Trace:
[ 2.144247] [<ffffffff812f00af>] ? dump_stack+0x5c/0x7d
optimizeForThisHost = pkg:
pkgs.lib.overrideDerivation pkg (old: {
CFLAGS = "${old.CFLAGS} -fPIC -O3 -march=native";
});
@matthiasbeyer
matthiasbeyer / fcode
Created March 5, 2018 18:46
bash function to find code and open it
fcode ()
{
[ "$#" -lt 1 ] && {
echo "Supply string to search for!";
return 1
};
printf -v search "%q" "$*";
local include="yml,js,json,php,md,html,config,py,cpp,c,go,hs,rb,conf,rs,txt";
local exclude=".config,.git,node_modules,vendor,build,yarn.lock,*.sty,*.bst,*.coffee,dist,*.aux,*.tmp";
rg_cmd='rg --column --line-number --no-heading --fixed-strings --ignore-case --follow --color always';
{ pkgs }:
rec {
optimizeWithFlag = pkg: flag:
pkg.overrideAttrs (attrs: {
NIX_CFLAGS_COMPILE = (attrs.NIX_CFLAGS_COMPILE or "") + " ${flag}";
});
optimizeWithFlags = pkg: flags:
pkgs.lib.foldl' (pkg: flag: optimizeWithFlag pkg flag) pkg flags;
@matthiasbeyer
matthiasbeyer / git-apply-github-pr
Created April 13, 2019 22:00
A script to apply github PRs as one commit
#!/usr/bin/env bash
while read line
do
patch=$(echo "$line" | sed
's,github\.com,patch-diff.githubusercontent.com/raw,; s,$,.patch,')
prnr=$(echo "$line" | sed 's,.*/,,')
curl $patch | git am -s || exit 1
#
# Copy this to ~/.config/sway/config and edit it to your liking.
#
# Read `man 5 sway` for a complete reference.
#
input * xkb_layout "de"
input * xkb_variant "nodeadkeys"
input 2:7:SynPS/2_Synaptics_TouchPad {
@matthiasbeyer
matthiasbeyer / example.rs
Created December 6, 2019 23:10
Context menu with Cursive
use cursive::event::{Event, Key};
use cursive::traits::*;
use cursive::views::{Dialog, EditView, OnEventView, TextArea};
use cursive::Cursive;
use cursive::view::Boxable;
use cursive::views::SelectView;
use cursive::event::EventResult;
use cursive::align::HAlign;
use cursive_context_menu::ContextMenu;
@matthiasbeyer
matthiasbeyer / remote-build.sh
Created October 13, 2020 09:14
execute nix-build remote
#!/usr/bin/env bash
host="$1"
branch="$2"
pkg="$3"
remote_dir="$$"
[[ -z "$host" ]] && { echo "no HOST"; exit 1; }
[[ -z "$branch" ]] && { echo "no branch"; exit 1; }
[[ -z "$pkg" ]] && { echo "no pkg"; exit 1; }