Skip to content

Instantly share code, notes, and snippets.

View avar's full-sized avatar

Ævar Arnfjörð Bjarmason avar

View GitHub Profile
@avar
avar / things-to-do-in-iceland.md
Last active June 27, 2023 18:31
Recommendations for things to do in Iceland

I get asked by people wanting to visit Iceland what they should do while they're there. Rather than re-type (and mostly forget) the whole thing I just give them a link to this.

Stuff that isn't this guide

...as if you didn't know how to use Google.

  • I'm partial to The Lonely Planet guides whenever I visit other places. I haven't checked the one for Iceland but it's probably
@avar
avar / .gitignore
Last active December 12, 2015 10:28
An example of a C# request to a Plack app with Auth::Basic middleware
*.exe
@avar
avar / git-training-topics.org
Last active December 11, 2015 05:28
A scratchpad for topics I'm covering in Git training.

-*- org -*-

Git Training

Topics to cover

Remember

Give the audience time to see the command-line fu

Explain stuff before you do it

Use ^SHIFT+L to clear the screen before the next example

@clintongormley
clintongormley / gist:3888120
Created October 14, 2012 09:44
Upgrading a running elasticsearch cluster

Yesterday I upgraded our running elasticsearch cluster on a site which serves a few million search requests a day, with zero downtime. I've been asked to describe the process, hence this blogpost.

To make it more complicated, the cluster was running elasticsearch version 0.17.8 (released 6 Oct 2011) and I upgraded it to the latest 0.19.10. There have been 21 releases between those two versions, with a lot of functional changes, so I needed to be ready to roll back if necessary.

Our setup:

  • elasticsearch

We run elasticsearch on two biggish boxes: 16 cores plus 32GB of RAM. All indices have 1 replica, so all data is stored on both boxes (about 45GB of data). The primary data for our main indices is also stored in our database. We have a few other indices whose data is stored only in elasticsearch, but are updated once daily only. Finally, we store our sessions in elasticsearch, but active sessions are cached in memcached.

@avar
avar / CustomizeFatal.pm
Created May 2, 2012 15:46
MooseX::Attribute::TypeConstraint::CustomizeFatal
package MooseX::Attribute::TypeConstraint::CustomizeFatal;
use Moose::Role;
use MooseX::Types::Moose ':all';
use Carp qw(confess);
use MooseX::Types -declare => [ qw(
TypeConstraintCustomizeFatalAction
) ];
use Data::Dumper;
use Try::Tiny;
@avar
avar / japan-ideas.md
Created April 10, 2012 10:17
Ideas for things to do in Japan
@avar
avar / dvorak-qwerty-analyzer.pl
Created March 17, 2012 20:26
Figure out how much of a given piece of text (on stdin) you type where with Dvorak/QWERTY
#!/usr/bin/env perl
use strict;
use Data::Dumper;
use List::Util qw(sum);
binmode STDIN, ":utf8";
binmode STDOUT, ":utf8";
my $text = do { local $/; scalar <> };
curl -XPUT localhost:9200/test -d '{
"settings" : {
"index.number_of_shards" : 1,
"index.number_of_replicas" : 0
}
}'
curl -XPUT localhost:9200/test/type/1 -d '{
"name" : "Awesometastic 1000",
"type" : "TV Remote"
curl -XPUT localhost:9200/test -d '{
"settings" : {
"index.number_of_shards" : 1,
"index.number_of_replicas" : 0
}
}'
curl -XPUT localhost:9200/test/type/1 -d '{
"name" : "Awesometastic 1000",
"type" : "TV Remote"
@nifgraup
nifgraup / lukrstats.sh
Created December 26, 2011 03:13
statistics on lukr importing, year later.
#/bin/bash
wget --timestamping http://download.geofabrik.de/osm/europe/iceland.osm.pbf
osmosis --read-pbf file=iceland.osm.pbf --way-key-value keyValueList=source.lukr --used-node --write-xml lukr.osm
osmosis --read-xml file=lukr.osm --way-key keyList=highway --used-node --write-xml lukrhighways.osm
xmllint --xpath '/osm/way/@user' lukrhighways.osm | grep -o user=\"[^\"]*\" > users.txt
echo "Skipting þeirra sem síðust breyttu lukr vegum:"
sort users.txt | uniq -c | sort -nr
echo "Fjöldi lukr vega sem búið er að staðfesta: `wc -l users.txt`"