Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env perl
use v5.12.0;
use File::Next;
use PPI;
my $basedir = shift // '.';
my $elements = shift // 'Token::Regexp';
@pmakholm
pmakholm / ppi.pl
Created April 11, 2013 10:15
Simple command line interface for PPI (Perl Parsing Interface)
#!/usr/bin/env perl
use v5.12.0;
use Getopt::Long;
use File::Next;
use PPI;
my ($match, $content) = qw(Element content);
my ($count, $verbose);
@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, {
#!/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 / 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>
}
@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
// ==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 / 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?
@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 / 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
#