Skip to content

Instantly share code, notes, and snippets.

View jdevera's full-sized avatar

Jacobo de Vera jdevera

View GitHub Profile
@jdevera
jdevera / vm-clean-up.sh
Last active May 18, 2024 18:39 — forked from mortn/vm-clean-up.sh
VM Clean Up (cleaning up Debian based system for use as template)
#!/bin/bash
# Clean up Apt
apt-get autoremove
apt-get autoclean
apt-get clean
# Generate new SSH host keys
for T in dsa rsa ecdsa; do
@jdevera
jdevera / namespaces-catalog.cljs
Created February 20, 2023 09:52
Namespaces Catalog for Roam Research (v.1.0)
(ns namespaces-catalog-v1.0
(:require [roam.datascript :as rd]
[roam.util :refer [parse]]))
(def SEP "/")
(defn namespaced-pages
" Get all pages in the graph that have a namespace (they contain / in the title)"
[]
(map first
@jdevera
jdevera / keybase.md
Created May 13, 2022 13:31
keybase.md

Keybase proof

I hereby claim:

  • I am jdevera on github.
  • I am jdevera (https://keybase.io/jdevera) on keybase.
  • I have a public key ASCyvaYAE57aihgMMYT4xo2vB9mKyY-AbG3OrWhW4xeazgo

To claim this, I am signing this object:

@jdevera
jdevera / die.py
Last active January 19, 2020 23:05
My most rewritten function: die
import sys
def die(*messages, rc=1):
"""
Print the arguments in stderr and exit with a given return code
"""
print(*messages, file=sys.stderr)
sys.exit(rc)
@jdevera
jdevera / python_path_fix.ps1
Created June 29, 2019 12:17
Make sure Python 2 is before Python 3 in the Windows PATH
$oldPath = (Get-ItemProperty -Path `
'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' `
-Name PATH).path
$pathParts = $oldPath.split(";")
$python = @()
$other = @()
foreach ($part in $pathParts) {
if ($part -like "*Python*") {
$python += ,$part
}
@jdevera
jdevera / unnecessary_select.py
Created May 31, 2019 20:17
SqlAchemy spurious select
import uuid
from sqlalchemy import Column, String, create_engine, CHAR
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///:memory:', echo=True)
Base = declarative_base()
@jdevera
jdevera / test_chicken.py
Created October 30, 2018 14:30
Example of Pytest parameterization of tests
import re
import pytest
def camel_to_snake(string):
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', string)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
CASES = [
@jdevera
jdevera / test_asyncio.py
Created October 25, 2018 10:00
Sync vs Async comparison in Python
import asyncio
import argparse
counter = 0
def next():
global counter
counter += 1
return counter
@jdevera
jdevera / tmuxp.sh
Created February 20, 2018 17:02 — forked from mlgill/tmuxp.sh
Execute parallel processes in arbitrary number of tmux panes
#!/bin/bash
# The "tmuxifier"
# Execute parallel processes in an arbitrary number of tmux panes
# This script requires the path to an existing script to
# execute in parallel. Optionally, the number of threads to
# and the name of the tmux session can be input. If threads
# and session name are not entered, threads are determined
# automatically and session names is set to a default.
@jdevera
jdevera / invalid_swagger_model.py
Created November 3, 2017 10:34
Create a model object without validation (useful for testing) in a generated Python Swagger Client
def make_invalid_model(model_class, **kwargs):
"""
create a model object bypassing all member validation
:param model_class: the class of the generated model that needs to be instantiated
:param kwargs: all the model parameters, as they would be passed to the constructor
:return: an instance of model_class
"""
def get_default_values(model_class, attributes):
signature = inspect.signature(model_class.__init__)