Skip to content

Instantly share code, notes, and snippets.

@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 / 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
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)
@ssebastianj
ssebastianj / deadlock.py
Created July 22, 2012 20:34
Script que simula el Algoritmo del Banquero para asignar recursos en un Sistema Operativo
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: Sebastián J. Seba
import itertools
class DeadLock(object):
def __init__(self, asignados, maximos, disponible):
@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
@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
@ssebastianj
ssebastianj / 98262.user.js
Last active March 28, 2017 03:00
Script para mostrar información ampliada sobre los exámenes tales como promedios generales, aplazos, ausentes y más.
// ==UserScript==
// @name UTN FRRe: SysAcad - Extra Info Exámenes
// @namespace http://sysacadweb.frre.utn.edu.ar
// @author Sebastián J. Seba
// @version 1.3.0
// @description Muestra información ampliada sobre los exámenes tales como promedios generales, aplazos, cantAusentes y más.
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html
// @include http://sysacadweb.frre.utn.edu.ar/examenes.asp
// @include http://sysacadweb.frre.utn.edu.ar/examenes.asp?id=*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
python -c "import pip, pprint; pprint.pprint([pkg.get_entry_map().get('console_scripts', '') for pkg in pip.get_installed_distributions()])"

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.