Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthias Beyer matthiasbeyer

View GitHub Profile
@matthiasbeyer
matthiasbeyer / git-diff-to.sh
Created Apr 17, 2021
diff a branch to a base branch
View git-diff-to.sh
#!/usr/bin/env bash
help() {
cat <<EOS
$0 [-h | --help] [base] [head]
Diff current branch (or [head], if passed) to [base]
EOS
}
View sway config
#
# 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 / lib.rs
Created Oct 15, 2020
Stream of buffers to stream of lines
View lib.rs
// should be all code...
use std::pin::Pin;
use std::result::Result as RResult;
use futures::Stream;
use futures::StreamExt;
use futures::task::Context;
use futures::task::Poll;
use anyhow::Error;
@matthiasbeyer
matthiasbeyer / remote-build.sh
Created Oct 13, 2020
execute nix-build remote
View remote-build.sh
#!/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; }
@matthiasbeyer
matthiasbeyer / example.rs
Created Dec 6, 2019
Context menu with Cursive
View example.rs
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 / git-apply-github-pr
Created Apr 13, 2019
A script to apply github PRs as one commit
View git-apply-github-pr
#!/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
View utils.nix
{ 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 / fcode
Created Mar 5, 2018
bash function to find code and open it
View fcode
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';
@matthiasbeyer
matthiasbeyer / configuration.nix
Created Jan 17, 2015
Nix config list ++ list attempt
View configuration.nix
# ... some things here ...
environment.systemPackages = let
basePkgs = import "${configDir}/pkgs/basePackages.nix" pkgs;
devPkgs = import "${configDir}/pkgs/devPackages.nix" pkgs;
desktopPkgs = import "${configDir}/pkgs/desktopPackages.nix" pkgs;
networkPkgs = import "${configDir}/pkgs/networkingPackages.nix" pkgs;
vim = import "${configDir}/pkgs/vim/default.nix" pkgs;
in
basePkgs ++ devPkgs ++ desktopPkgs ++ networkPkgs ++ vim;
@matthiasbeyer
matthiasbeyer / select_remind_entry.sh
Last active Mar 8, 2017
remind entry to ics with selection
View select_remind_entry.sh
#!/bin/bash
#
# The following script is a ugly hack. But it works, so yeah \m/
#
# It uses awk, cut, head, tail, rem2ics and fzf (whereas this is only for the
# selection-process and could be replaced).
#
# Purpose:
#