Skip to content

Instantly share code, notes, and snippets.

Avatar

Steinn Eldjárn Sigurðarson steinnes

View GitHub Profile
@steinnes
steinnes / 01_setup_swap.config
Last active Oct 30, 2019
EB config file which executes setup_swap.sh
View 01_setup_swap.config
container_commands:
01setup_swap:
command: "bash .ebextensions/setup_swap.sh"
@steinnes
steinnes / bug_report_rules.md
Last active Aug 6, 2019
Three golden rules for bug reports
View bug_report_rules.md

"3" Golden Rules for Bug Reports

A common problem with bug reports, according to developers, is that they are often too vague to be helpful. This can frustrate both reporters and developers, and damage an otherwise productive and positive scenario.

If a report is vague, it becomes extremely hard to fix. Why? Because the developer may not be able understand what was going on (from the vague description) and is very unlikely to be able to duplicate the behavior.

Thankfully it is extremely easy to prevent this from happening -- we just need to make your sure our bug reports answer three simple questions:

  1. What did I do?
@steinnes
steinnes / usage.md
Last active Nov 2, 2018
A shellscript which hangs for up to 30 seconds while waiting for a port to become accessible.
View usage.md

A simple way to test this is to run wait_for_port.sh against localhost on a random unused port:

$ .ci/wait_for_port.sh localhost 12345
.....

Then in another shell, listen on that port:

$ nc -l 12345
@steinnes
steinnes / setup_swap.sh
Created Mar 15, 2016
swapfile setup script
View setup_swap.sh
#!/bin/bash
SWAPFILE=/var/swapfile
SWAP_MEGABYTES=2048
if [ -f $SWAPFILE ]; then
echo "Swapfile $SWAPFILE found, assuming already setup"
exit;
fi
View utf8-magic.py
import sys
UTF8Writer = codecs.getwriter('utf8')
class SafeStdoutWriter(UTF8Writer):
""" A safe stdout writer class which expects to output only unicode string objects
but if it encounters a decoding error (because the given string is not unicode but
a normal 'str') it will attempt to convert it to unicode and try again. If that
conversion fails we fall back to decoding iso-8859-1 which is the default codec
the CSVOutput writer uses.
View keybase.md

Keybase proof

I hereby claim:

  • I am steinnes on github.
  • I am steinnes (https://keybase.io/steinnes) on keybase.
  • I have a public key ASBhjE9xWeYPkNk07XoFpdyknK8dxarE3VhcJ6VQbFwQjQo

To claim this, I am signing this object:

@steinnes
steinnes / circle-ci-env-variables.txt
Created Feb 9, 2017
Circle CI environment variables
View circle-ci-env-variables.txt
# This is a list of Circle CI environment variables, pulled on Feb 9th 2017 @ 00:10
# This can be useful for example when running tests inside a docker and you wish to
# pass environment variables into the docker via docker-compose. That's why I made
# this list by starting a build with SSH enabled, and executing:
#
# ubuntu@box103:~$ env|grep ^CI|cut -d\= -f1|sort -u
CI
CI_PULL_REQUEST
CI_PULL_REQUESTS
@steinnes
steinnes / nginx.conf
Created Dec 30, 2016
nginx config to listen on IPv6 and proxy
View nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
@steinnes
steinnes / synchronize.py
Created May 15, 2016
python threading lock example
View synchronize.py
import threading
import time
from functools import wraps
FN_LOCKS = {}
class Lock(object):
def __init__(self, func_id):
global FN_LOCKS
View sally.py
import time
timings = (
(1, 'up'),
(2, 'down'),
(7, 'up'),
(8, 'down'),
(13, 'up'),
(14, 'down'),
(19, 'up'),