Skip to content

Instantly share code, notes, and snippets.

Avatar

Ævar Arnfjörð Bjarmason avar

View GitHub Profile
View brute-tag-cmp.sh
#!/bin/bash
for i in $(seq 10 100); do
echo "$i ($(date)):"
git rev-list origin/master|perl -0777 -nE "srand($i); my @r = sort { rand() <=> rand() } split /\n/, \$_; for (0..8) { say qq[\$r\[\$_\]:\$r\[-\$_\]] }" >/tmp/commit-list
#cat /tmp/commit-list
echo ".. doing faster ($(date)):"
parallel -k -j 8 '
A=$(echo {} | cut -d: -f1)
View gitweb.pl
$line = esc_html($line, -nbsp=>1);
$line =~ s{
\b
(
# The output of "git describe", e.g. v2.10.0-297-gf6727b0
# or hadoop-20160921-113441-20-g094fb7d
View p6-psgi.pl
use v5.14.2;
use strict;
use warnings;
use Inline::Perl6;
my $p6 = Inline::Perl6->new;
my $app = sub {
my @ret = $p6->run(<<'P6');
sub main {
View squid.conf
http_port 127.0.0.1:3128
http_access allow localhost manager
http_access deny manager
http_access allow localhost
http_access deny all
cache_peer webproxy.corp.example.com parent 3128 0 no-query proxy-only default ssl sslflags="DONT_VERIFY_PEER NO_DEFAULT_CA DONT_VERIFY_DOMAIN"
never_direct allow all
cache deny all
access_log daemon:/var/log/squid3/access.log squid
cache_log /var/log/squid3/cache.log
View git-index-helper-strace
) = 1 (in [3], left {569, 430925})
accept(3, 0, NULL) = 4
fcntl(4, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR) = 0
read(4, "", 1) = 0
close(4) = 0
select(4, [3], NULL, NULL, {600, 0}) = 1 (in [3], left {599, 999375})
accept(3, 0, NULL) = 4
fcntl(4, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(4, F_SETFL, O_RDWR) = 0
@avar
avar / safely_write.pl
Last active Aug 29, 2015
An example of writing long JSON lines to a file atomically with Perl while warning about writes in excess of PIPE_BUF
View safely_write.pl
use strict;
use warnings;
use JSON::XS ();
use POSIX qw(PIPE_BUF);
my $PATH = ...;
my $DATA = ...;
my $TIME = time;
my $JSON = JSON::XS->new->ascii(1)->indent(0);
@avar
avar / prune-benchmark.sh
Last active Aug 29, 2015
Ad-hoc benchmark script for git fetch --prune v.s. git remote prune
View prune-benchmark.sh
#!/bin/bash -xe
# Clone git.git
cd /tmp/
rm -rf git
if ! test -d git
then
git clone --reference ~/g/git https://code.google.com/p/git-core/ git
fi
@avar
avar / build-perl6-from-git
Created Feb 5, 2015
A very basic builder for the Perl 6 MoarVM+NQP+Rakudo distributions, which installs them into a given target
View build-perl6-from-git
#!/bin/sh -xe
root=/tmp/usr
prefix=$root/local/my-perl6/blead
work=/tmp/perl6-git
jobs=18
rm -rfv $root $work || :
mkdir $work
cd $work
View faq-diff.txt
diff --git a/faq.fmt b/faq.fmt
index a671bc6..d5511e7 100644
--- a/faq.fmt
+++ b/faq.fmt
@@ -56,12 +56,12 @@ surface and make the first in-situ subsurface analysis of its composition.
It will also be the first mission to investigate a comet’s nucleus
and environment over an extended period of time.
-How will Rosetta reach comet 67P/Churyumov-Gerasimenko, and how long will
-it take? Comet 67P/Churyumov-Gerasimenko loops around the Sun between
@avar
avar / redis-expiry.pl
Last active Aug 29, 2015
Test the Redis SCAN command
View redis-expiry.pl
use strict;
use warnings;
use Redis;
my $what = $ARGV[0] || "create";
my $r = Redis->new(server => "127.0.0.1:6379");
my $num_keys = 100_000;