Skip to content

Instantly share code, notes, and snippets.

Avatar

Tomasz Janowski janaz

View GitHub Profile
@janaz
janaz / collectd-speedtest.sh
Created Sep 12, 2020
Speedtest script for collectd-exec plugin
View collectd-speedtest.sh
#!/bin/sh
HOSTNAME="${COLLECTD_HOSTNAME:-localhost}"
INTERVAL="${COLLECTD_INTERVAL:-3600}"
while true; do
result="$(speedtest --csv)"
upload="$(echo "$result" | cut -d, -f8)"
download="$(echo "$result" | cut -d, -f7)"
echo "PUTVAL \"$HOSTNAME/speedtest/upload\" interval=$INTERVAL N:$upload"
echo "PUTVAL \"$HOSTNAME/speedtest/download\" interval=$INTERVAL N:$download"
@janaz
janaz / get-aws-console-url.js
Last active Jan 23, 2022
Generate AWS console URL from the credentials stored in environment variables
View get-aws-console-url.js
/**
* This little program prints out the url to the AWS console
* generated from the local AWS credentials stored in environment variables:
* AWS_ACCESS_KEY_ID
* AWS_SECRET_ACCESS_KEY
* AWS_SESSION_TOKEN
*
* Steps:
* 1. Create a JSON object
* session = JSON.stringify({
@janaz
janaz / preso.sh
Created Mar 3, 2019
Daemons in Bash
View preso.sh
#!/bin/bash
SLEEP=0.005
COLS=$(tput cols)
ROWS=$(tput lines)
RED="\033[0;31m"
YELLOW="\033[0;33m"
GREEN="\033[0;32m"
BLUE="\033[0;34m"
@janaz
janaz / cond.js
Last active Nov 16, 2018
no conditionals
View cond.js
const population = [ [], [], [], [], [], [] ];
population[3][4] = false;
//-------------------------------------------
const population = new Population();
const cell = new AliveCell();
const position = new Position(3, 4);
population.set(position, cell);
class Cell {}
@janaz
janaz / lambda-compression.md
Last active Jun 28, 2018
Lambda function - compression comparison
View lambda-compression.md

Environment

$ ls -1 .
node_modules
package.json
src
yarn.lock

$ du -sm .
@janaz
janaz / cors_server.py
Last active Apr 23, 2016 — forked from enjalot/cors_server.py
Allow CORS with python simple http server
View cors_server.py
import sys
import SimpleHTTPServer
class CORSHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def send_head(self):
path = self.translate_path(self.path)
f = None
if os.path.isdir(path):
if not self.path.endswith('/'):
# redirect browser - doing basically what apache does
self.send_response(301)
@janaz
janaz / docker-overlay.sh
Created Oct 31, 2015
Create docker-machine with overlayfs
View docker-overlay.sh
docker-machine create -d virtualbox --engine-storage-driver overlay --virtualbox-disk-size "50000" --virtualbox-memory "4096" overlay
@janaz
janaz / Dockerfile
Last active Jan 25, 2022
sharp - dockerfile
View Dockerfile
FROM ubuntu:14.04
ENV DEBIAN_FRONTEND noninteractive
RUN echo "System updated on 2015-06-25" && apt-get update && apt-get -y dist-upgrade
# Install dependencies
RUN \
apt-get install -y \
automake build-essential curl\
View install-mapnik-amazon-ami.sh
# http://aws.amazon.com/amazon-linux-ami/
# http://aws.amazon.com/amazon-linux-ami/faqs/
# Boot up a machine with at least 1.5 to 2 GB Ram
# login
chmod 600 key.pem
ssh -i key.pem ec2-user@ec2...compute.amazonaws.com
# update