Skip to content

Instantly share code, notes, and snippets.

@alxbnct
alxbnct / yplay.scm
Created March 14, 2023 04:09 — forked from jjwatt/yplay.scm
The Y Combinator explained in a runnable Scheme file
View yplay.scm
;;; The Y Combinator explained in scheme.
;;; with credits to:
;;; https://mvanier.livejournal.com/2897.html
;;; Status: WIP
(define fibonacci
(lambda (n)
(cond ((= n 0) 0)
((= n 1) 1)
(else (+ (fibonacci (- n 1)) (fibonacci (- n 2)))))))
@alxbnct
alxbnct / ssh-forward-clipboard.md
Created March 8, 2023 02:35 — forked from dergachev/ssh-forward-clipboard.md
Forward your clipboard via SSH reverse tunnels
View ssh-forward-clipboard.md

Exposing your clipboard over SSH

I frequently administer remote servers over SSH, and need to copy data to my clipboard. If the text I want to copy all fits on one screen, then I simply select it with my mouse and press CMD-C, which asks relies on m y terminal emulator (xterm2) to throw it to the clipboard.

This isn't practical for larger texts, like when I want to copy the whole contents of a file.

If I had been editing large-file.txt locally, I could easily copy its contents by using the pbcopy command:

@alxbnct
alxbnct / firewall.sh
Created September 4, 2022 09:50 — forked from furdarius/firewall.sh
Iptables desktop firewall
View firewall.sh
#!/bin/bash
#Simple Firewall Script.
#Add "pre-up iptables-restore < /etc/iptables.rules" to /etc/network/interfaces
#Setting up default kernel tunings here (don't worry too much about these right now, they are acceptable defaults) #DROP ICMP echo-requests sent to broadcast/multi-cast addresses.
echo 1 > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
#DROP source routed packets
echo 0 > /proc/sys/net/ipv4/conf/all/accept_source_route
#Enable TCP SYN cookies
echo 1 > /proc/sys/net/ipv4/tcp_syncookies
@alxbnct
alxbnct / openbsd_vbox_resolution.sh
Created September 1, 2022 12:59 — forked from kasramp/openbsd_vbox_resolution.sh
Set OpenBSD screen resolution on Virtualbox
View openbsd_vbox_resolution.sh
#!/bin/sh
# inspired by https://www.tumfatig.net/20190131/customized-resolution-for-openbsd-in-virtualbox/
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root"
exit 1
fi
mkdir -p /etc/X11/xorg.conf.d
@alxbnct
alxbnct / host_vbox_custom_resolution.sh
Created September 1, 2022 12:59 — forked from kasramp/host_vbox_custom_resolution.sh
Set screen resolution on Virtualbox (host machine)
View host_vbox_custom_resolution.sh
#!/bin/sh
if [ -z "$1" ] || [ -z "$2" ]; then
echo "Pass VBox machine name and screen resolution"
echo "Example: 'OpenBSD New' '1920x1080x32'"
exit 1
fi
VBoxManage setextradata "$1" CustomVideoMode1 "$2"
@alxbnct
alxbnct / unbond.conf
Created August 20, 2022 14:37 — forked from MatthewVance/unbond.conf
Example of how to configure Unbound as a local forwarder using DNS-over-TLS to forward queries.
View unbond.conf
server:
###########################################################################
# BASIC SETTINGS
###########################################################################
# Time to live maximum for RRsets and messages in the cache. If the maximum
# kicks in, responses to clients still get decrementing TTLs based on the
# original (larger) values. When the internal TTL expires, the cache item
# has expired. Can be set lower to force the resolver to query for data
# often, and not trust (very large) TTL values.
cache-max-ttl: 86400
@alxbnct
alxbnct / advanced_search.markdown
Created August 19, 2022 12:08 — forked from dohsimpson/advanced_search.markdown
Advanced Search Tricks
View advanced_search.markdown

Google

  • "cocotte bag": exact match
  • "* is thicker than water": * to replace a phrase inside exact match
  • jaguar -car: minus to filter out matches
  • site:time.com google: search on site, you don't need '.', e.g. 'site:gov'
  • define:bae: check definition, even for slang
  • $0..$50: numeric range (ignore $)
  • "inbound marketing" ~professional: synonyms
  • related:nationalgeographic.com: similar sites
@alxbnct
alxbnct / gist:b3731647a8f7940f9891b839cc5b54ac
Created July 17, 2022 14:44 — forked from jatcwang/gist:ae3b7019f219b8cdc6798329108c9aee
List of all setxkbmap configuration options (including models/layout/etc)
View gist:b3731647a8f7940f9891b839cc5b54ac
! model
pc101 Generic 101-key PC
pc102 Generic 102-key (Intl) PC
pc104 Generic 104-key PC
pc105 Generic 105-key (Intl) PC
dell101 Dell 101-key PC
latitude Dell Latitude series laptop
dellm65 Dell Precision M65
everex Everex STEPnote
flexpro Keytronic FlexPro
@alxbnct
alxbnct / signing-gpg-keys.md
Created July 11, 2022 03:30 — forked from F21/signing-gpg-keys.md
Signing someone's GPG key
View signing-gpg-keys.md

This is a quick guide of the commands we use to sign someone's GPG key in a virtual key signing party.

Note: The steps cover only the technical aspects of signing someone's key. Before signing someone's key, you must verify their identity. This is usually done by showing government-issued ID and confirming the key's fingerprint

The commands will work for both GPG and GPG2.

I use Julian's key for the examples. His key id is 2AD3FAE3. You should substitute with the appropriate key id when running the commands.

Signing the key

  1. List the keys currently in your keyring: gpg --list-keys.
@alxbnct
alxbnct / gpg2qrcodes.sh
Created July 9, 2022 06:07 — forked from joostrijneveld/gpg2qrcodes.sh
Producing printable QR codes for persistent storage of GPG private keys
View gpg2qrcodes.sh
# Heavily depends on:
# libqrencode (fukuchi.org/works/qrencode/)
# paperkey (jabberwocky.com/software/paperkey/)
# zbar (zbar.sourceforge.net)
# Producing the QR codes:
# Split over 4 codes to ensure the data per image is not too large.
gpg --export-secret-key KEYIDGOESHERE | paperkey --output-type raw | base64 > temp
split temp -n 4 IMG
for f in IMG*; do cat $f | qrencode -o $f.png; done