Skip to content

Instantly share code, notes, and snippets.

@pmakholm
pmakholm / sandboxed-chrome.sh
Created November 5, 2018 08:49
Run Google Chrome with restricted access to $HOME
#!/bin/sh
# This runs Google Chrome in a sandboxed environment with
# only restricted access to $HOME
#
# Requires bubblewrap https://github.com/projectatomic/bubblewrap
#
# TODO: Create a minimal /dev
exec bwrap --ro-bind / / \
@pmakholm
pmakholm / dynamic_path.sh
Created June 8, 2018 11:29
.bashrc snippet to handle git working tree specific PATH
# .bashrc snippet to handle git working tree specific PATH
REAL_PATH=$PATH
PATH_SUFFIX='$( git rev-parse --git-dir &> /dev/null && echo $(git rev-parse --show-toplevel)/bin: )
PROMPT_COMMAND='eval PATH=$PATH_SUFFIX$REAL_PATH'
@pmakholm
pmakholm / update-followers.pl
Last active June 8, 2018 08:56
Script to maintain a twitter list of tweeps following me with no follow back.
#!/usr/bin/perl
# Rough script to maintain a twitter list with tweeps following me without
# being followed back
#
# Requirements:
# - Install twurl from https://github.com/twitter/twurl
# - Follow the 'Getting started' section of the README for twurl
# - Set your twitter username and list name below
#
@pmakholm
pmakholm / lovkatalog.mkd
Created October 3, 2017 13:11
IT Lovkatalog

GDPR

Forsvarsministeren

Ændring af lov om Center for Cybersikkerhed (Konsekvensændringer som følge af databeskyttelsesforordningen) (Feb II)

Formålet med lovforslaget er at gennemføre konsekvensændringer som følge af EU’s databeskyttelsesforordning, der får virkning fra den 25. maj 2018.

Justitsministeren

@pmakholm
pmakholm / fosdem16.lightning.txt
Last active October 23, 2015 14:17
Lightning talk for Fosdem'16
Title: Securing Wordpress
Subtitle: Reducing collatteral damage from insecure web applications
Abstract:
I am not proud of it, but I use Wordpress for a few personal web sites. To
be true, I'm not good at keeping my Wordpress install updated, and I'm not
proud of that either.
Defacements and data-loss are an acceptable risk: my sites do not need high
availability and I have backups (I think). But what about the risks I put
others in if my webserver gets compromised?
// ==UserScript==
// @name Version2 fix-up
// @namespace http://peter.makholm.net/
// @version 0.1
// @description Invasive fix-up for the design on version2.dk
// @author Peter Makholm
// @match http://www.version2.dk/
// @match http://www.version2.dk/*
// @grant none
// ==/UserScript==
@pmakholm
pmakholm / example
Last active August 29, 2015 14:16
Unpriviledged LXC application container with bind mounted system
# Set up a new LXC container:
lxc-create -n sandbox -t $(pwd)/lxc-sandbox.template -f $(pwd)/lxc-sandbox.conf --dir $( mktemp -d -p $(pwd)/ lxc-XXXXXX )
# Run a single process in the container:
lxc-execute -n sandbox -q -- bash
@pmakholm
pmakholm / expressive.nqp
Created November 23, 2013 11:24
Compiler for a very simple language
#!/usr/bin/env nqp-p
use NQPHLL;
grammar Expressive::Grammar is HLL::Grammar {
token TOP {
:my $*CUR_BLOCK := QAST::Block.new(QAST::Stmts.new());
<statementlist>
}
#!/usr/bin/perl
use strict;
use warnings;
use Parallel::ForkManager;
my $pm = Parallel::ForkManager->new(8);
for my $file (glob "/usr/local/backup/*") {
my $pid = $pm->start and next;
@pmakholm
pmakholm / gist:5821490
Created June 20, 2013 09:35
Benchmark of listing files in directory in perl: ls vs glob vs readdir
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark qw(cmpthese);
qx(ls -1U); # Populate dir cache
cmpthese(1000, {