Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am varokas on github.
  • I am varokas (https://keybase.io/varokas) on keybase.
  • I have a public key whose fingerprint is D830 E8A8 1AF7 53F8 AD23 8260 0701 C740 FB8D 24E9

To claim this, I am signing this object:

@varokas
varokas / api_gateway.json
Last active February 2, 2021 04:51
AWS Lambda Events
{
"body": "eyJ0ZXN0IjoiYm9keSJ9",
"resource": "/{proxy+}",
"path": "/path/to/resource",
"httpMethod": "POST",
"isBase64Encoded": true,
"queryStringParameters": {
"foo": "bar"
},
"multiValueQueryStringParameters": {
@varokas
varokas / sum.hs
Last active December 2, 2020 22:18
sum of digit power
-- Decompose Int to arrays of digits
digits :: Integral a => a -> [a]
digits x
| x < 10 = [x]
| otherwise = digits(x `div` 10) ++ [x `mod` 10]
-- x to the 4th
power4 x = x^4
-- What is asked
@varokas
varokas / food.py
Last active October 18, 2020 21:17
food.py
#!/usr/bin/python3
from collections import defaultdict
import sys
individual_indicator = "east"
by_name = defaultdict(list)
by_item = defaultdict(list)
individual = defaultdict(list)
@varokas
varokas / daily_backup.sh
Last active April 20, 2020 01:17
Ghost Daily Backup
#!/bin/bash
current_date=`date +%Y%m%d`
mysql_backup_filename="mysql-"$current_date
mysql_backup_filename_gz=$mysql_backup_filename".gz"
content_backup_filename="content-"$current_date".tar.gz"
tar -C /home/ubuntu -czf /home/ubuntu/$content_backup_filename ghost
/usr/local/bin/docker-compose -f /home/ubuntu/docker-compose.yml exec db /usr/bin/mysqldump -u root --password=<some_password> ghost > /home/ubuntu/$mysql_backup_filename
gzip -f /home/ubuntu/$mysql_backup_filename
@varokas
varokas / Caddyfile
Last active April 20, 2020 00:23
Ghost Docker Compose file
www.<your_domain>.com
reverse_proxy ghost:2368
@varokas
varokas / handler.py
Created April 14, 2020 08:16
Serverless python
import json
import numpy as np
def hello(event, context):
a = np.arange(10)
response = {
"statusCode": 200,
"body": json.dumps({ "sum": int(np.sum(a)) })
@varokas
varokas / Caddyfile
Created April 12, 2020 20:30
Caddy as a reverse proxy
www.varokas.com
reverse_proxy ghost:2368
@varokas
varokas / mysql-docker.sh
Created April 11, 2020 19:18 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@varokas
varokas / docker-compose.yml
Created April 1, 2020 06:39
Jupyter in docker-compose
version: '3'
services:
jupyter:
image: jupyter/pyspark-notebook:latest
ports:
- "8888:8888"
- "4040:4040"
volumes:
- .:/home/jovyan
environment: