Skip to content

Instantly share code, notes, and snippets.

@odedlaz
odedlaz / nginx-docker-compose.yml
Created July 27, 2017 12:48
A simple docker-compose file for nginx
version: '3'
services:
web:
image: nginx
network_mode: "host"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 80:80
#!/usr/bin/env python
import pika
import time
import sys
import json
name = 'hello ' + sys.argv[1]
connection = pika.BlockingConnection(
pika.ConnectionParameters(host='localhost'))
@odedlaz
odedlaz / weather-forecast.py
Last active December 27, 2017 16:06
weather-geolocation-script
#!/usr/bin/env python
# sh is mighty! have a look: https://github.com/amoffat/sh
from sh import awk, iwlist
import requests
import sys
import os
__dir__ = os.path.dirname(os.path.realpath(__file__))

Keybase proof

I hereby claim:

  • I am odedlaz on github.
  • I am odedlaz (https://keybase.io/odedlaz) on keybase.
  • I have a public key whose fingerprint is 5017 D338 3F64 1ADF 43C6 EF9D 515C 0ACE 5D29 39A2

To claim this, I am signing this object:

@odedlaz
odedlaz / get-clang-6.0.sh
Last active April 24, 2019 13:53
Install Clang 6.0
#!/usr/bin/env bash
set -euo pipefail
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
code_name=$(lsb_release -c | awk '{ print $2}')
@odedlaz
odedlaz / vssh.fish
Last active March 26, 2021 23:50
vssh
#!/usr/bin/env fish
# add the following line to ~/.config/fish/completions in order to add hostname completion to the script
# complete -x -c vssh -d "Remote" -a "(__fish_complete_user_at_hosts)"
function get_gateway --argument addr
route -n get -net $addr | awk '/gateway/ { print $2 }'
end
function get_global_protect_interface_ipaddr_from_config
@odedlaz
odedlaz / safe_readlines.py
Created December 22, 2021 18:21
str.readlines that yields the lines. instead of reading a file into memory and splitting all lines, use this function to read line-by-line
def safe_readlines(f, block_size=32, max_file_size=1024 * 1024):
read = 0
buf = ""
read_block = functools.partial(f.read, 32)
for block in map(bytes.decode, iter(read_block, b'')):
assert read + block_size <= max_file_size, "manifest file is too big"
read += len(block)
first, *rest = block.splitlines()