Skip to content

Instantly share code, notes, and snippets.

<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin root@example.com
DocumentRoot /var/www/html/example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www/html/example.com">
# Who has contributed the most to your repository? Both in terms of
# net additions, and total changes. (Just change $_->{loc_net} to
# $_->{loc_tot} at the end of the command.
(printf -- '---\nchanges:\n'; git log --stat --format=' - name: %aE' | grep -v -e \| -e ^$ | sed -re 's/[^,]+, / loc: /' -e 's/([0-9]+) insertions?\(\+\)/\1/' -e 's/(, )?([0-9]+) deletions?\(-\)/-\2/' ) | perl -MYAML -MData::Dumper -E '$db = Load(do { local $/; <> })->{changes}; @p = map { { loc_net => eval "$_->{loc}", loc_tot => eval($_->{loc} =~ s/-/+/r) , name => $_->{name} } } @$db; print Dump \@p' | perl -MYAML -E '$db = Load(do { local $/; <> }); my $h = {}; $h->{$_->{name}} += $_->{loc_net} for @$db; print Dump $h' | sort
import random
class DontExperiment(Exception):
pass
def experiment(rate=0.1):
"""
Generate an experiment decatorator; it will raise an DontExperiment
exception with a probability of <rate>.
@olof
olof / gist:436be0ac6f35ee31966c4161ef21c48f
Created October 31, 2016 18:52
little endian hex to big endian dot decimal notation
perl -E 'say join(".", map {hex} reverse( shift =~ /(..)/g ) )' 0100007F
# Credit to Martinus at
# http://www.irishastronomy.org/index.php?option=com_kunena&view=topic&Itemid=211&catid=28&id=90354
# make your screen only show red tones
for c in green blue; do
xcalib -$c .1 0 1 -alter
done
# reset it with "xcalib -clear".
@olof
olof / get_infohash.sh
Created July 30, 2016 15:33
Get info hash from torrent file
perl -M5.010 \
-MFile::Slurp -MYAML -MBencode=bdecode,bencode -MDigest::SHA=sha1_hex \
-e 'say sha1_hex bencode bdecode(scalar read_file shift)->{info}' \
<torrentfile>
@olof
olof / gist:10991534
Last active August 29, 2015 13:59
centered printf strings
printf "====[ %3s%-3s ]====\n",
substr($title, 0, length($title)/2),
substr($title, length($title)/2);
@olof
olof / dnspkt.erl
Created June 27, 2013 16:12
Parsing a DNS packet with erlang. Learning erlang kind of thing. Not complete, but can parse up to, and including, the question section.
% vim: ts=2:sw=2:noet:tw=80
% dnspkt.erl: Parse a dns query packet.
% Copyright 2013, Olof Johansson <olof@ethup.se>
%
% Copying and distribution of this file, with or without
% modification, are permitted in any medium without royalty
% provided the copyright notice are preserved. This file is
% offered as-is, without any warranty.
@olof
olof / gist:4537120
Created January 15, 2013 08:07
Vim highlighting trailing whitespace
" hilight trailing whitespace
highlight wsEOL ctermbg=red guibg=red
match wsEOL /\v\s+$/
au InsertLeave * match wsEOL /\v\s+$/
au InsertEnter * match wsEOL /\v\s+\%#\@<!$/
qsort1([]) -> [];
qsort1([H|T]) -> qsort1([X||X<-T,X<H])++[H]++qsort1([X||X<-T,X>=H]).