Skip to content

Instantly share code, notes, and snippets.

@mb720
mb720 / bash.rc
Created May 21, 2018 15:00
Keybinding to open file selected with fzf in editor
# Search a file with fzf and then open it in an editor
fzf_then_open_in_editor() {
local file=$(fzf)
# Open the file if it exists
if [ -n "$file" ]; then
# Use the default editor if it's defined, otherwise Vim
${EDITOR:-vim} "$file"
fi
}
bind -x '"C-o": fzf_then_open_in_editor'
@mb720
mb720 / BigIntAddition.hs
Created June 28, 2018 10:49
Exercise in BigInt addition for Haskell
import Data.Int(Int8)
import Data.List(foldl')
import Test.QuickCheck
type Digit = Int8
-- Feedback on a prior version of this code: https://codereview.stackexchange.com/questions/195150/haskell-bigint-addition
-- Run checkAdd to test it with QuickCheck
-- Adds two integer lists.
@mb720
mb720 / screen_brightness.sh
Created December 1, 2019 17:41
Script for changing monitor brightness on Linux. Could be mapped to the XF86MonBrightnessUp and XF86MonBrightnessDown keys.
#!/usr/bin/env bash
# Changes the monitor brightness.
# Usage examples: "screen_brightness.sh +500", "screen_brightness 3000"
if (( $# >= 1 )); then
argument="$1"
# Writing to this file changes the monitor brightness.
# The parentheses are used to have a wildcard for the
2020-02-15 18:31:29 - [sway/main.c:152] Linux marathon 5.5.3-arch1-1 #1 SMP PREEMPT Tue, 11 Feb 2020 15:35:41 +0000 x86_64 GNU/Linux
2020-02-15 18:31:29 - [sway/main.c:168] Contents of /etc/os-release:
2020-02-15 18:31:29 - [sway/main.c:152] NAME="Arch Linux"
2020-02-15 18:31:29 - [sway/main.c:152] PRETTY_NAME="Arch Linux"
2020-02-15 18:31:29 - [sway/main.c:152] ID=arch
2020-02-15 18:31:29 - [sway/main.c:152] BUILD_ID=rolling
2020-02-15 18:31:29 - [sway/main.c:152] ANSI_COLOR="0;36"
2020-02-15 18:31:29 - [sway/main.c:152] HOME_URL="https://www.archlinux.org/"
2020-02-15 18:31:29 - [sway/main.c:152] DOCUMENTATION_URL="https://wiki.archlinux.org/"
2020-02-15 18:31:29 - [sway/main.c:152] SUPPORT_URL="https://bbs.archlinux.org/"
Feb 15 18:58:18 marathon systemd-coredump[849225]: Process 849196 (vlc) of user 1001 dumped core.
Stack trace of thread 849223:
#0 0x00007fa7d9232d24 __pthread_mutex_lock (libpthread.so.0 + 0xbd24)
#1 0x00007fa7d51bffe3 wl_proxy_create_wrapper (libwayland-client.so.0 + 0x6fe3)
#2 0x00007fa7b592d10c n/a (libEGL_mesa.so.0 + 0x2310c)
#3 0x00007fa7b591590f n/a (libEGL_mesa.so.0 + 0xb90f)
#4 0x00007fa77e80a622 n/a (libegl_wl_plugin.so + 0x1622)
#5 0x00007fa7d8f77964 n/a (libvlccore.so.9 + 0x2e964)
#6 0x00007fa7d8f77f21 vlc_module_load (libvlccore.so.9 + 0x
Feb 15 18:36:42 marathon audit[804494]: ANOM_ABEND auid=1001 uid=1001 gid=1001 ses=1 pid=804494 comm="vlc" exe="/usr/bin/vlc" sig=11 res=1
Feb 15 18:36:42 marathon kernel: vlc[804521]: segfault at 50 ip 00007f10f3f90f65 sp 00007f109d916450 error 4 in libwayland-client.so.0.3.0[7f10f3f90000+5000]
Feb 15 18:36:42 marathon kernel: Code: 84 24 d0 00 00 00 48 8b 72 10 ba 14 00 00 00 48 89 44 24 18 44 89 e0 48 8d 04 40 c7 44 24 0c 30 00 00 00 48 8d 04 c6 4c 89 f6 <48> 8b 78 08 67 e8 f1 23 00 00 4c 89 e9 4c 89 f2 44 89 e6 48 89 ef
Feb 15 18:36:42 marathon kernel: audit: type=1701 audit(1581788202.278:88): auid=1001 uid=1001 gid=1001 ses=1 pid=804494 comm="vlc" exe="/usr/bin/vlc" sig=11 res=1
Feb 15 18:36:42 marathon audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@8-804562-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Feb 15 18:36:42 marathon systemd[1]: Started Process Core Dump (PID 804562/UID 0).
Feb 15 18:36:42 marathon kern
Feb 15 18:31:58 marathon audit[794549]: ANOM_ABEND auid=1001 uid=1001 gid=1001 ses=1 pid=794549 comm="Xwayland" exe="/usr/bin/Xwayland" sig=6 res=1
Feb 15 18:31:59 marathon kernel: audit: type=1701 audit(1581787918.916:85): auid=1001 uid=1001 gid=1001 ses=1 pid=794549 comm="Xwayland" exe="/usr/bin/Xwayland" sig=6 res=1
Feb 15 18:31:59 marathon kernel: audit: type=1130 audit(1581787918.940:86): pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@7-794560-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Feb 15 18:31:58 marathon audit[1]: SERVICE_START pid=1 uid=0 auid=4294967295 ses=4294967295 msg='unit=systemd-coredump@7-794560-0 comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=? res=success'
Feb 15 18:31:58 marathon systemd[1]: Started Process Core Dump (PID 794560/UID 0).
Feb 15 18:32:00 marathon systemd-coredump[794561]: Process 794549 (Xwayland) of user 1001 dumped core.
@mb720
mb720 / s_box.rs
Last active October 17, 2021 18:47
AES S-Box in Rust
let s_box = [
[0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76],
[0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0],
[0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15],
[0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75],
[0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84],
[0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf],
[0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8],
[0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2],
[0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73],
@mb720
mb720 / sway_debug.log
Created August 21, 2022 11:09
Sway debug log
00:00:00.000 [INFO] [sway/main.c:343] Sway version 1.7
00:00:00.000 [INFO] [sway/main.c:344] wlroots version 0.15.1
00:00:00.005 [INFO] [sway/main.c:120] Linux zurich 5.19.2-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 17 Aug 2022 13:48:51 +0000 x86_64 GNU/Linux
00:00:00.005 [INFO] [sway/main.c:136] Contents of /etc/os-release:
00:00:00.005 [INFO] [sway/main.c:120] NAME="Arch Linux"
00:00:00.005 [INFO] [sway/main.c:120] PRETTY_NAME="Arch Linux"
00:00:00.005 [INFO] [sway/main.c:120] ID=arch
00:00:00.005 [INFO] [sway/main.c:120] BUILD_ID=rolling
00:00:00.005 [INFO] [sway/main.c:120] ANSI_COLOR="38;2;23;147;209"
00:00:00.005 [INFO] [sway/main.c:120] HOME_URL="https://archlinux.org/"