Skip to content

Instantly share code, notes, and snippets.

@ssebastianj
ssebastianj / README.md
Last active October 17, 2022 20:42
Use @nedbat 's Cog to rewrite Python code snippet in examples Markdown file

Cogging the examples

$ python3 -m venv .venv
$ . ./venv/bin/activate
$ python -m pip install --upgrade pip pip-tools
$ python -m piptools compile --generate-hashes -o requirements.txt -r requirements.in
$ python -m piptools sync requirements.txt
$ python -m cogapp -erP examples.md
@ssebastianj
ssebastianj / healthcheck.sh
Last active May 1, 2019 13:34
Run ping, netcat, host (or any other) commands on multiple hosts or IPs or both. Also run many procresses at a time!
#!/usr/bin/env bash
set -euo pipefail
# In some commands, I've used the full parameter names just for the sake of learning/debugging/memorizing.
# From $ man xargs:
# --max-procs
# Run up to max-procs processes at a time; the default is 1.
# If max-procs is 0, xargs will run as many processes as possible at a time.
ls config 2>/dev/null # Answer <y> to run proposed fix | <ENTER> to skip proposed fix | <Ctrl+C> to exit
ls -la config 2>/dev/null # <Ctrl+C> if the issue was resolved | Answer <y> to try current fix | <ENTER> to skip current fix
ls -lAh config 2>/dev/null # <Ctrl+C> if the issue was resolved | Answer <y> to try current fix | <ENTER> to skip current fix
tree -L 1 config 2>/dev/null # <Ctrl+C> if the issue was resolved | Answer <y> to try current fix | <ENTER> to skip current fix
echo 'End' # No more fixes to try. If the issue was not resolved please open an issue on https://github.com/project/issues / <ENTER> to exit
import types
def attach_docstring(value, docstring: str):
class_name = type(value).__name__
class_bases = (type(value),)
build_body = lambda ns: ns.update({"__doc__": docstring})
return types.new_class(class_name, class_bases, exec_body=build_body)(value)

Types

A type is a collection of possible values. An integer can have values 0, 1, 2, 3, etc.; a boolean can have values true and false. We can imagine any type we like: for example, a HighFive type that allows the values "hi" or 5, but nothing else. It's not a string and it's not an integer; it's its own, separate type.

Statically typed languages constrain variables' types: the programming language might know, for example, that x is an Integer. In that case, the programmer isn't allowed to say x = true; that would be an invalid program. The compiler will refuse to compile it, so we can't even run it.

python -c "import pip, pprint; pprint.pprint([pkg.get_entry_map().get('console_scripts', '') for pkg in pip.get_installed_distributions()])"
@ssebastianj
ssebastianj / bindkey.md
Last active December 26, 2023 06:34
zsh bindkey commands
Shortcut Action
CTRL+@ set-mark-command
CTRL+A beginning-of-line
CTRL+B backward-char
CTRL+D delete-char-or-list
CTRL+E end-of-line
CTRL+F forward-char
CTRL+G send-break
CTRL+H backward-delete-char
@ssebastianj
ssebastianj / owasp-top-10-proactive-controls-2016-summary.md
Created August 3, 2016 12:34
OWASP Top 10 Controls 2016 Summary

OWASP Top 10 Proactive Controls 2016

Ordered by order of importance, with control number 1 being the most important.

  1. Verify for security early and often.
  2. Parameterize queries.
  3. Encode data.
  4. Validate all inputs.
  5. Implement identity and authentication controls.
  6. Implemente appropiate access controls.

Setup

Servidores DNS de Google IP
Primario 8.8.8.8
Secundario 8.8.4.4
Servidores DNS de Arnet IP
Primario 200.45.191.35
@ssebastianj
ssebastianj / api.md
Last active November 13, 2018 04:25
¿Cuándo Pasa Resistencia? API Reverse Engineering

¿Cuándo Pasa Resistencia?

API

1. Identificador de usuario

El identificador de usuario userId a utilizar en las peticiones está en función del tipo de línea de colectivo que se desea consultar (urbana o interurbana).

Línea UserId
Urbana 0d7c6b60-7b7f-4833-ace7-e633dc1a33c9
Interurbana 30d72c97-568b-4dcb-b239-13c0a318348c