Skip to content

Instantly share code, notes, and snippets.

View wsgac's full-sized avatar

Wojciech S. Gac wsgac

  • Iagon
  • Warszawa, Poland
View GitHub Profile

Pi approximation

return 355.0/113.0

#+RESULTS[65a3244f1a752173c45b62a7685331f3f22836dc]: pi

3.14159292035

Earth’s surface [km^2]

@wsgac
wsgac / haskell.el
Created January 17, 2017 09:50
A work-in-progress Emacs configuration for Haskell
;;;;;;;;;;;;;;;;;;;
;; ;;;;;;;;;;;;; ;;
;; ;; Haskell ;; ;;
;; ;;;;;;;;;;;;; ;;
;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;
;; Prerequisites ;;
;;;;;;;;;;;;;;;;;;;
;; (package-install 'haskell-mode)
@wsgac
wsgac / 40-libinput.conf
Last active July 2, 2019 23:12
CST Laser Trackball Xorg configuration
# Alternative to 'evdev'. I needed this one to get CST working under Suse Tumbleweed.
Section "InputClass"
Identifier "CST Trackball"
MatchProduct "Clearly Superior Technologies. CST Laser Trackball"
Driver "libinput"
Option "ScrollMethod" "button"
Option "ScrollButton" "2"
Option "HorizontalScrolling" "true"
Option "MiddleEmulation" "true"
@wsgac
wsgac / morse.lisp
Created February 4, 2019 17:24
StumpWM utilities for Morse code encoding/decoding
;; -*- lisp -*-
;; Morse code decoder
(defparameter *morse-code-decoder* (make-hash-table :test #'equal))
(setf (gethash ".-" *morse-code-decoder*) "a")
(setf (gethash "-..." *morse-code-decoder*) "b")
(setf (gethash "-.-." *morse-code-decoder*) "c")
(setf (gethash "-.." *morse-code-decoder*) "d")
(setf (gethash "." *morse-code-decoder*) "e")
(setf (gethash "..-." *morse-code-decoder*) "f")
@wsgac
wsgac / Bell.qs
Created February 8, 2019 16:39
Implementation of a Bell pair creation operator in Q# together with the corresponding C# driver
namespace Bell
{
open Microsoft.Quantum.Canon;
open Microsoft.Quantum.Primitive;
// Qubit setter
operation Set (desired: Result, q1: Qubit) : Unit {
let current = M(q1);
if (desired != current) {
X(q1);
@wsgac
wsgac / .tmux.conf
Created February 11, 2019 15:30
Override Tmux's window switcher to display pane numbers upon switch
# Invoke our custom command when switching windows
bind -T prefix n run "tmux-switch-windows n"
bind -T prefix p run "tmux-switch-windows p"
@wsgac
wsgac / .bashrc
Created February 11, 2019 15:36
Graphical selectors for Docker containers
# -*- bash -*-
# These functions require 'dmenu', available as part of the Suckless Tools package
# Ubuntu/Debian: sudo apt install suckless-tools
# Select Docker container from Dmenu and return its ID
function select-container {
echo $(docker ps --format 'table {{.Image}}\t{{.ID}}\t{{.Status}}\t{{.Names}}' | tail -n +2 | dmenu -l 10 | awk '{print $2}')
}
# Go to desired Docker container based on Dmenu selection
@wsgac
wsgac / menu-selector.sh
Last active November 22, 2022 09:32
Fallback selector - uses 'dmenu' under Xorg, 'select' otherwise
# -*- bash -*-
# This is a small selector function inspired, and making use of,
# 'dmenu' from Suckless Tools. Based on the lines piped to it, it
# prompts the user to select one and then returns that choice. When
# run under Xorg, it will make use of 'dmenu', otherwise the builtin
# 'select' construct will be used, providing a fallback mechanism.
function menu-selector {
declare -a items=()
@wsgac
wsgac / .tmux.conf
Last active July 25, 2024 11:53
Attempt to emulate Emacs registers in Tmux
# -*- conf -*-
# Initialize alphanumerical registers to avoid the problem with 'delete-buffer'
run "tmux set-buffer -b a \"$(echo ' ')\""
run "tmux set-buffer -b b \"$(echo ' ')\""
run "tmux set-buffer -b c \"$(echo ' ')\""
run "tmux set-buffer -b d \"$(echo ' ')\""
run "tmux set-buffer -b e \"$(echo ' ')\""
run "tmux set-buffer -b f \"$(echo ' ')\""
run "tmux set-buffer -b g \"$(echo ' ')\""
@wsgac
wsgac / lookup.lisp
Last active July 2, 2019 15:00
Interactive dictionary/Google lookup fro StumpWM
;; -*- lisp -*-
(ql:quickload :quri) ; For encoding URLs
(in-package :stumpwm)
;; My preferred key bindings
(define-key *top-map* (kbd "s-d") "lookup-selection")
(define-key *top-map* (kbd "s-g") "google-selection")