Skip to content

Instantly share code, notes, and snippets.

View janaz's full-sized avatar

Tomasz Janowski janaz

View GitHub Profile
# 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
@janaz
janaz / Dockerfile
Last active January 25, 2022 03:55
sharp - 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\
@janaz
janaz / docker-overlay.sh
Created October 31, 2015 03:05
Create docker-machine with overlayfs
docker-machine create -d virtualbox --engine-storage-driver overlay --virtualbox-disk-size "50000" --virtualbox-memory "4096" overlay
@janaz
janaz / cors_server.py
Last active April 23, 2016 14:37 — forked from enjalot/cors_server.py
Allow CORS with python simple http server
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 / lambda-compression.md
Last active June 28, 2018 07:28
Lambda function - compression comparison

Environment

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

$ du -sm .
@janaz
janaz / cond.js
Last active November 16, 2018 14:37
no conditionals
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 / preso.sh
Created March 3, 2019 06:37
Daemons in Bash
#!/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 / get-aws-console-url.js
Last active March 27, 2024 12:05
Generate AWS console URL from the credentials stored in environment variables
/**
* 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 / collectd-speedtest.sh
Created September 12, 2020 12:50
Speedtest script for collectd-exec plugin
#!/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"