Skip to content

Instantly share code, notes, and snippets.

@latenssi
latenssi / lorem_pixels.py
Last active December 29, 2015 17:49
Django lorem pixels
import os,urllib
from random import choice
from django.conf import settings
TYPES = [
'abstract',
'city',
'people',
'transport',
'animals',
@latenssi
latenssi / rivit.py
Created May 8, 2014 20:53
Bestest Lotto
import random
import sys
no_balls = 39
no_rows = 6
row_length = 7
fillers = (32, 39)
if no_balls > row_length * no_rows:
sys.exit('Too many balls!')

Keybase proof

I hereby claim:

  • I am latenssi on github.
  • I am laurijunkkari (https://keybase.io/laurijunkkari) on keybase.
  • I have a public key ASA-JQHVrnZHuW7j8BoGR47j3luWLUvKepDIpu09KBk8ygo

To claim this, I am signing this object:

@latenssi
latenssi / hyphencaseToCamelcase.js
Last active April 13, 2017 06:50
Hyphencase to Camelcase
const hyphencaseToCamelcase = s => s.replace(/(\-\w)/g, m => m[1].toUpperCase());
@latenssi
latenssi / timestamp.txt
Created June 6, 2017 05:55
Linux timestamps
date --date='TZ="Europe/London" 12:00 tomorrow' +%s%N | cut -b1-13
@latenssi
latenssi / edit_file.sh
Last active August 16, 2018 10:33
Rmate remote editing
rmate test.txt
@latenssi
latenssi / ecr-helper.md
Last active December 4, 2018 08:59
AWS ECR helper
  1. Clone the git repository https://github.com/awslabs/amazon-ecr-credential-helper.git

  2. cd to the cloned folder "amazon-ecr-credential-helper"

  3. Run the command on terminal "make docker" (it will create the binary "./bin/local/docker-credential-ecr-login")

  4. Copy this binary to /usr/bin with the command " sudo cp ./bin/local/docker-credential-ecr-login /usr/bin/docker-credential-ecr-login

  5. Create or modify the docker config.json file available at /.docker/config.json with the below content

const IPFS = require("ipfs");
const OrbitDB = require("orbit-db");
const ipfs = new IPFS({
repo: "./ipfs",
EXPERIMENTAL: {
pubsub: true
}
});
@latenssi
latenssi / hc-cmd.py
Created April 10, 2019 06:54
Generate healthchecks
from __future__ import print_function
import os
import json
try:
from urllib.request import Request, urlopen # Python 3
except ImportError:
from urllib2 import Request, urlopen # Python 2
@latenssi
latenssi / container.sh
Created April 10, 2019 07:28
Healthchecks
#!/bin/bash
SERVICE_NAME=
FAIL_URL=
OK_URL=
if [ -z `docker ps -q --no-trunc | grep $(docker-compose ps -q $SERVICE_NAME)` ];
then curl -fsS --retry 3 $FAIL_URL;
else curl -fsS --retry 3 $OK_URL;
fi