Skip to content

Instantly share code, notes, and snippets.

Avatar
🗿
〰️〰️〰️〰️

Richard de Wit richarddewit

🗿
〰️〰️〰️〰️
View GitHub Profile
@richarddewit
richarddewit / su
Created Sep 16, 2020
A `su` replacement using machinectl
View su
#!/usr/bin/env bash
if [[ "$1" == "-" ]]; then
shift
fi
if [ -z "$1" ]; then
echo "Missing argument USER"
exit 1
fi
@richarddewit
richarddewit / keymap.c
Created Apr 1, 2020
Tokyo60 / Tsangan keymap
View keymap.c
#include QMK_KEYBOARD_H
// Layers
#define _BASE 0 // Base (QWERTY)
#define _FN 3 // Function
#define BASE DF(_BASE)
// Aliases
#define ___V___ KC_TRNS
@richarddewit
richarddewit / drag_bin_file_here_to_flash.bat
Last active Mar 26, 2020
Flash (Mass)Drop keyboards firmware bin file
View drag_bin_file_here_to_flash.bat
@ECHO OFF
ECHO Flashing file %~1
ECHO.
mdloader_windows.exe --first --download "%~1" --restart
PAUSE
@richarddewit
richarddewit / README.md
Last active Dec 24, 2019
Rails 6 & Svelte with preloaded data
View README.md

Rails 6 & Svelte with preloaded data

rails new rails-6-svelte --webpack=svelte
cd rails-6-svelte
rails generate controller welcome index
View poebuildscc-sort-popular.js
@richarddewit
richarddewit / undefined-constant-CrystalCodegenTarget.patch
Last active Jul 3, 2019
Patch for "undefined constant Crystal::Codegen::Target" error - crystal-lang-tools/scry v0.8.0
View undefined-constant-CrystalCodegenTarget.patch
diff --git a/src/scry/completion_provider.cr b/src/scry/completion_provider.cr
index 29e0d36..f67438c 100644
--- a/src/scry/completion_provider.cr
+++ b/src/scry/completion_provider.cr
@@ -1,4 +1,5 @@
require "./log"
+require "compiler/crystal/codegen/target"
require "compiler/crystal/crystal_path"
require "./completion/*"
@richarddewit
richarddewit / _pre-commit-check-console-log.sh
Last active Jun 26, 2019 — forked from svschannak/gist:8d1a445a751d5ae8e18ef9b98a45be9f
Git pre-commit hook that detects if the developer forget to remove all the javascript console.log before commit.
View _pre-commit-check-console-log.sh
#!/bin/sh
# Redirect output to stderr.
exec 1>&2
# enable user input
exec < /dev/tty
consoleregexp='^\+.*console\.log('
# CHECK
if test $(git diff --cached | grep $consoleregexp | wc -l) != 0
then
@richarddewit
richarddewit / hostsmanager.sh
Last active Mar 8, 2019 — forked from irazasyed/manage-etc-hosts.sh
Bash script to manage /etc/hosts file, adding/removing hostnames.
View hostsmanager.sh
#!/usr/bin/env bash
if [ "$1" != "add" ] && [ "$1" != "remove" ] || [ -z "$2" ]; then
[ -z "$2" ] && echo "Missing hostname" || echo "Unknown option '$1'"
echo "Unknown option '$1'"
echo "Usage:"
echo " $0 add <hostname>"
echo " $0 remove <hostname>"
exit 1
fi
@richarddewit
richarddewit / vagrant-sudoers-arch-fedora.sh
Last active Jan 2, 2019 — forked from elvetemedve/Arch Linux, Fedora
Allow Vagrant usage without providing sudo password
View vagrant-sudoers-arch-fedora.sh
#
# Arch Linux / Fedora sudoers entries
#
sudo tee /etc/sudoers.d/vagrant > /dev/null << EOL
# Allow passwordless startup of Vagrant with vagrant-hostsupdater.
Cmnd_Alias VAGRANT_HOSTS_ADD = /bin/sh -c echo "*" >> /etc/hosts
Cmnd_Alias VAGRANT_HOSTS_REMOVE = /usr/bin/sed -i -e /*/ d /etc/hosts
%wheel ALL=(root) NOPASSWD: VAGRANT_HOSTS_ADD, VAGRANT_HOSTS_REMOVE
@richarddewit
richarddewit / randomIBANs.py
Last active Jan 15, 2019
Generate X random IBANs for Dutch bank ABN
View randomIBANs.py
#!/usr/bin/env python
import sys
import random
def main():
try:
count = int(sys.argv[1])
if count <= 0:
raise ValueError
You can’t perform that action at this time.