Skip to content

Instantly share code, notes, and snippets.

View fstamour's full-sized avatar

Francis St-Amour fstamour

View GitHub Profile
Verifying that +francisstamour is my blockchain ID. https://onename.com/francisstamour
@fstamour
fstamour / replace-prefix-if-present.el
Created June 2, 2016 19:31
Small emacs lisp function "If STRING starts with PREFIX, replace the PREFIX by NEW-PREFIX. Else, returns NIL."
(defun replace-prefix-if-present (string prefix new-prefix)
"If STRING starts with PREFIX, replace the PREFIX by NEW-PREFIX.
Else, returns NIL."
(if (string-prefix-p prefix string)
(concat new-prefix (substring string (length prefix)))
nil))
(defun slime-eval-save-output (string)
"Evaluate STRING in Lisp and save the result in the kill ring."
(slime-eval-async `(swank:eval-and-grab-output ,string)
(lambda (result)
(cl-destructuring-bind (output value) result
(kill-new output)
(message "Evaluation finished; pushed output to kill ring.")))))
(defun lisp-eval-defun-in-kill-ring ()
#!/usr/bin/env python3
import sys
import http.client
import json
if __name__ == '__main__':
if len(sys.argv) < 2:
print("USAGE: gist.py gist-id")
sys.exit(1)
#!/usr/bin/env bash
brightness_file=/sys/class/backlight/acpi_video0/actual_brightness
set_brightness () {
nvidia-settings -n -a BacklightBrightness=$(cat $brightness_file) > /dev/null
}
watch () {
inotifywait -m -e modify $brightness_file |
@fstamour
fstamour / xmodmap-replace-shift-by-menu
Created July 31, 2017 00:55
A really small xmodmap configuration file to replace the righ shift with the "menu" button (also called "application" button)
! Replace right shift with menu
clear Shift
keysym Shift_R = Menu
add Shift = Shift_L
@fstamour
fstamour / start_ssh_agent_if_not_running.sh
Created August 28, 2017 17:23
Start ssh agent if not running and save environment variable to share the agent across shell. Useful on Windows.
start_ssh_agent_if_not_running () {
local SSH_ENVIRONMENT_FILE=~/.ssh/environment
if [ -f "$SSH_ENVIRONMENT_FILE" ]; then
source "$SSH_ENVIRONMENT_FILE"
fi
echo SSH_AGENT_PID='"'${SSH_AGENT_PID}'"'
if [ ! -z ${SSH_AGENT_PID} ] && ps -p ${SSH_AGENT_PID} > /dev/null
then
@fstamour
fstamour / config-termite
Created February 8, 2018 01:01
Termite (a terminal emulator) configuration (mostly for colors)
# To place in ~/.config/termite/config
[options]
resize_grip = false
scroll_on_output = false
scroll_on_keystroke = true
audible_bell = false
visible_bell = false
mouse_autohide = false
allow_bold = true
@fstamour
fstamour / watch.js
Created August 15, 2018 23:03
Poor man's nodemon
const spawn = require('child_process').spawn;
const fs = require('fs');
function debounce(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
nix search quicklisp
nix-env -i lisp-quicklisp
quicklisp init
quicklisp run
quicklisp install alexandria
quicklisp update