Skip to content

Instantly share code, notes, and snippets.

View rodfersou's full-sized avatar

Rodrigo Ferreira de Souza rodfersou

  • Londrina - PR, Brazil
View GitHub Profile
@rodfersou
rodfersou / .gitignore
Created December 9, 2023 01:40 — forked from datakurre/.gitignore
Multi-kernel Jupyter notebook environment and Docker container with Nix
*.ipynb
*.png
*.tar.gz
.ipynb_checkpoints
.ipython
.jupyter
.sentinel.*
@rodfersou
rodfersou / README
Created August 19, 2023 05:27 — forked from jmatsushita/README
Setup nix, nix-darwin and home-manager from scratch on an M1 Macbook Pro
###
### [2023-06-19] UPDATE: Just tried to use my instructions again on a fresh install and it failed in a number of places.
###. Not sure if I'll update this gist (though I realise it seems to still have some traffic), but here's a list of
###. things to watch out for:
### - Check out the `nix-darwin` instructions, as they have changed.
### - There's a home manager gotcha https://github.com/nix-community/home-manager/issues/4026
###
# I found some good resources but they seem to do a bit too much (maybe from a time when there were more bugs).
# So here's a minimal Gist which worked for me as an install on a new M1 Pro.
# get total requests by status code
awk '{print $9}' /var/log/nginx/access.log | sort | uniq -c | sort -rn
# get top requesters by IP
awk '{print $1}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requesters by user agent
cut -d' ' -f12- /var/log/nginx/access.log | sort | uniq -c | sort -rn | head
# get top requests by URL
@rodfersou
rodfersou / beautiful_idiomatic_python.md
Last active March 4, 2016 20:43 — forked from JeffPaine/beautiful_idiomatic_python.md
Transforming Code into Beautiful, Idiomatic Python: notes from Raymond Hettinger's talk at pycon US 2013. The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Transforming Code into Beautiful, Idiomatic Python

Notes from Raymond Hettinger's talk at pycon US 2013 video, slides.

The code examples and direct quotes are all from Raymond's talk. I've reproduced them here for my own edification and the hopes that others will find them as handy as I have!

Looping over a range of numbers

for i in [0, 1, 2, 3, 4, 5]:
# XXX -- Top level review comments:
#
# * Nice exception recovery and logging.
#
# * Please cleanup code formatting.
# This is a little rough on my eyes.
#
# * Should we use this as template for other
# short network element scripts?
#
from nettools import NetworkElement
with NetworkElement('171.0.2.45') as ne:
for route in ne.routing_table:
print '%15s -> %s' % (route.name, route.ipaddr)
import jnettool.tools.Routing
import jnettool.tools.elements.NetworkElement
class NetworkElementError(Exception):
pass
class NetworkElement(object):