Skip to content

Instantly share code, notes, and snippets.

View nhamilakis's full-sized avatar
🎱
pondering on quests

Hamilakis Nicolas nhamilakis

🎱
pondering on quests
View GitHub Profile
@m-radzikowski
m-radzikowski / script-template.sh
Last active October 26, 2024 11:24
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@amarao
amarao / blame-praise.py
Last active September 23, 2024 02:22
Example of argparse with subparsers for python
#!/usr/bin/env python
import argparse
def main(command_line=None):
parser = argparse.ArgumentParser('Blame Praise app')
parser.add_argument(
'--debug',
action='store_true',
help='Print debug info'
This work, excluding the Arch Linux logo, is made available under CC0: https://creativecommons.org/publicdomain/zero/1.0/
@joshbode
joshbode / LICENSE.md
Last active August 1, 2024 20:37
YAML Loader with include constructor (Python 3)

MIT License

Copyright (c) 2018 Josh Bode

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@mvpotter
mvpotter / download_file.py
Created February 19, 2014 09:08
Download large files using python
def download_file(url):
local_filename = url.split('/')[-1]
# NOTE the stream=True parameter
r = requests.get(url, stream=True)
with open(local_filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
if chunk: # filter out keep-alive new chunks
f.write(chunk)
f.flush()
return local_filename