Skip to content

Instantly share code, notes, and snippets.

@ahungry
ahungry / gist:94c8e255d6931b1cb2af
Last active January 21, 2016 04:16
Caesar Cipher with Common Lisp Glyphs package
(ƒ caesar-cipher
α → (let ((n (or αb 11)))
(coerce (ψ (ψ (coerce α 'list)
α → (mod (- (+ (char-code α) n) 97) 26))
α → (code-char (+ 97 α))) 'string)))
Common Lisp using my package https://github.com/ahungry/glyphs
@ahungry
ahungry / post.php
Created January 23, 2016 06:19
Safely get post data or defaults
<?php
function post($key, $default = '')
{
return isset($_POST[$key]) ? $_POST[$key] : $default;
}
$name = post('name', 'Jon Smith');
@ahungry
ahungry / _reader-macros.md
Created May 19, 2016 01:21 — forked from chaitanyagupta/_reader-macros.md
Reader Macros in Common Lisp

Reader Macros in Common Lisp

This post also appears on lisper.in.

Reader macros are perhaps not as famous as ordinary macros. While macros are a great way to create your own DSL, reader macros provide even greater flexibility by allowing you to create entirely new syntax on top of Lisp.

Paul Graham explains them very well in [On Lisp][] (Chapter 17, Read-Macros):

The three big moments in a Lisp expression's life are read-time, compile-time, and runtime. Functions are in control at runtime. Macros give us a chance to perform transformations on programs at compile-time. ...read-macros... do their work at read-time.

@ahungry
ahungry / stumpwmrc.lisp
Created June 2, 2016 06:07
send in special unicode chars np
(defcommand wss (string) ()
"Send a string of characters, including non-ascii ones (needs work for more than 1 char at a time)"
(map nil (lambda (ch)
(let* ((char-code (char-code ch))
(keysym (+ char-code (if (>= char-code #x100) #x01000000 0)))) ;; Only applicable if code >= #x100
(xlib:change-keyboard-mapping
*display*
(make-array '(1 1) :initial-element keysym)
;;#2A(
;;#(16778171) ;; λ in slot 8
@ahungry
ahungry / Get-TLS-Fingerprint.sh
Created June 7, 2016 16:51 — forked from r35krag0th/Get-TLS-Fingerprint.sh
Get Pandora TLS Fingerprint
#!/bin/bash
##
## A simple little shell script that will return the current
## fingerprint on the SSL certificate. It's crude but works :D
##
## Author: Bob Saska (r35krag0th) <git@r35.net>
openssl s_client -connect tuner.pandora.com:443 < /dev/null 2> /dev/null | \
openssl x509 -noout -fingerprint | tr -d ':' | cut -d'=' -f2
@ahungry
ahungry / etter.el
Created August 30, 2016 16:06
Etter
# -*- mode: snippet -*-
# name: typed getter/setter/property of class
# key: tetter
# --
/** @var $2 */
private $$1;
/**
* @return $2 Return the set value
*/
cat /etc/systemd/system/backlight.service
[Unit]
Description=Fix the laptop backlight
[Service]
ExecStart=/usr/local/bin/brightfix.sh
[Install]
WantedBy=multi-user.target
@ahungry
ahungry / arch-linux-install
Created June 27, 2019 00:42 — forked from mattiaslundberg/arch-linux-install
Minimal instructions for installing arch linux on an UEFI system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system and UEFI
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX bs=16M && sync # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
# Set swedish keymap
@ahungry
ahungry / arch-linux-install-encryption
Created June 27, 2019 00:43 — forked from dust321/arch-linux-install-encryption
Minimal instructions for installing Arch Linux on an DOS/BIOS system with full system encryption using dm-crypt and luks
# Install ARCH Linux with encrypted file-system, for BIOS. Dustin dut n ex 5 a t g ma il
# The official installation guide (https://wiki.archlinux.org/index.php/Installation_Guide) contains a more verbose description.
# Download the archiso image from https://www.archlinux.org/
# Copy to a usb-drive
dd if=archlinux.img of=/dev/sdX # on linux
# Boot from the usb. If the usb fails to boot, make sure that secure boot is disabled in the BIOS configuration.
#!/bin/sh
# install needed curl package
sudo apt install --no-install-recommends curl -y
# install kubectl
# https://github.com/kubernetes/minikube/issues/3437#issuecomment-449408316, maybe use https://storage.googleapis.com/minikube/releases/v0.30.0/docker-machine-driver-kvm2
curl -Lo /tmp/kubectl https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
chmod +x /tmp/kubectl && \
sudo mv /tmp/kubectl /usr/local/bin/kubectl
# kubectl tab completion
sudo sh -c 'echo "source <(kubectl completion bash)" > /etc/bash_completion.d/kubectl'