Skip to content

Instantly share code, notes, and snippets.

@torgeir
torgeir / tomb.sh
Created March 12, 2023 11:28
Tomb encrypted mount
tar xvfz Tomb-2.9.tar.gz
cd Tomb-2.9
sudo make install
# 300MB disk
tomb dig -s 300 locked.tomb
tomb forge locked.tomb.key
@torgeir
torgeir / resize-home-folder-partition-on-ubuntu-snappy-core-on-the-raspberry-pi-2.md
Last active January 27, 2023 14:36
Resize home folder partition on ubuntu snappy core on the raspberry pi 2

Note where home is

(RaspberryPi2)root@localhost:~# df -h /home/
Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p4   1.6G 1.3G   160M  89% /oem
(RaspberryPi2)root@localhost:~# df -h
@torgeir
torgeir / aws-stream-logs-from-cloudwatch-lambda-es--lambda-code.js
Created August 4, 2016 12:18
AWS stream logs from "cloudwatch -> lambda -> es" node.js lambda-code
// v1.1.2
var https = require('https');
var zlib = require('zlib');
var crypto = require('crypto');
var endpoint = '<aws es endpoint>';
exports.handler = function(input, context) {
// decode input from base64
var zippedInput = new Buffer(input.awslogs.data, 'base64');
@torgeir
torgeir / cp_with_progress
Created January 12, 2013 16:56
`cp` with progress bar (on os x)
brew install pv
echo "cp_with_progress() { pv < $1 > $2; }" >> .profile
# restart shell
cp_with_progress somefile somenewfile
@torgeir
torgeir / pico-2022.clj
Created December 12, 2022 19:07
The beginning of pico ctf 2022
(ns pico)
;; basic-mod1
;;
(def data [91 322 57 124 40 406 272 147 239 285 353 272 77 110 296 262 299 323 255 337 150 102])
(def alph
"0-25 is the alphabet (uppercase), 26-35 are the decimal digits, and 36 is an underscore."
@torgeir
torgeir / nuke-disk.sh
Created September 10, 2022 09:47
Nuke a disk, single pass
# https://wiki.archlinux.org/title/Securely_wipe_disk
❯ sudo shred --verbose --random-source=/dev/urandom -n1 --zero /dev/sdX
shred: /dev/sdb: pass 1/2 (random)...
shred: /dev/sdb: pass 1/2 (random)...134MiB/932GiB 0%
shred: /dev/sdb: pass 1/2 (random)...319MiB/932GiB 0%
shred: /dev/sdb: pass 1/2 (random)...503MiB/932GiB 0%
@torgeir
torgeir / zoom-mute-status-setup.md
Last active October 13, 2022 21:21
Example configurations for AnyBar and Ubsersicht to get a visual cue representing your zoom mute status. Credits https://gist.github.com/tyhawkins/66d6f6ca8b3cb30c268df76d83020a64
@torgeir
torgeir / wine-tkg-fsync-arch-build.sh
Last active August 14, 2022 19:21
Wine tkg with fsync support for running helix native on arch
cd
git clone git@github.com:Frogging-Family/wine-tkg-git.git Code/wine-tkg-git
pushd Code/wine-tkg-git/wine-tkg-git
git checkout master
# vim customizations.cfg: _staging_version="v7.15", _use_fsync="true"
# why tho?
rm -rf wine-tkg-patches/hotfixes/mfplat
# select 0, the customizations has settings for fsync
@torgeir
torgeir / codingame-snake-ai.kt
Last active June 26, 2022 15:14
Codingame: Snake AI, random safe moves
import java.util.*
import java.lang.Integer.parseInt
typealias Coord = Pair<Int, Int>
fun Coord.x() = first
fun Coord.y() = second
typealias Move = Pair<Direction, Coord>
@torgeir
torgeir / prototypes.js
Created November 29, 2011 09:17
javascript's __proto__ and prototype explained
/**
* __proto__ and prototype
* - the __proto__ property the instance's 'parent' up the prototype chain
* - the prototype property refers what new instances of the type will have their __proto__ set to, i.e. what will be the new instance's 'parent' up the prototype chain
*/
/* Given */
function Object () {}
Object.prototype = {
__proto__: null