Skip to content

Instantly share code, notes, and snippets.

View jorgeas80's full-sized avatar
🎯
Focusing

Jorge Arévalo jorgeas80

🎯
Focusing
View GitHub Profile
@jorgeas80
jorgeas80 / unzip_to_dir.py
Created April 15, 2021 21:21
Unzips all files in a dir, extracting the files one by one, with a rusty status report
import os, zipfile
import sys
dir_name = sys.argv[1] if len(sys.argv) > 1 else None
extension = sys.argv[2] if len(sys.argv) > 2 else ".zip"
if not dir_name:
print("No dir name")
sys.exit(1)
{
"basics": {
"name": "Jorge Arevalo",
"label": "Python/Django Web Developer",
"summary": "I’m a software developer since 2007. Specialized in web development with Python and Django. Previous experience with C as developer of GDAL PostGIS Raster driver and PostGIS Raster extension. Also experience as tech trainer.",
"website": "https://about.me/jorgeas80",
"email": "[email protected]",
"location": {
"city": "Madrid",
"countryCode": "ES"
@jorgeas80
jorgeas80 / ren.sh
Created March 20, 2020 10:00
Batch rename files in a dir to a sequential name by file date
#!/bin/bash
a=1
for i in *.png; do
new=$(printf "%04d.png" "$a") #04 pad to length of 4
mv -i -- "$i" "$new"
let a=a+1
done
@jorgeas80
jorgeas80 / pdb_tricks
Last active January 27, 2020 14:00
A few useful tricks when debugging code with [i]pdb
# Put a breakpoint in a file that is not part of our code
# Ref: https://stackoverflow.com/q/13589736/593722
(Pdb) import sys
(Pdb) sys.path.append("/home/user/path/to/another/module")
(Pdb) import another_module
(Pdb) b another_module:356
Breakpoint 1 at /home/user/path/to/another/module/another_module.py:356
(Pdb) c
# Conditionally hit the breakpoint #1
@jorgeas80
jorgeas80 / regexp.sh
Created January 14, 2020 16:23
Useful regexp
# Delete starting and ending blank spaces
s/^\s+|\s+$|\s+(?=\s)
# Delete duplicated lines, after sorting
^(.+)$\n^\1$
@jorgeas80
jorgeas80 / docker_cheatsheet
Last active January 27, 2020 10:09
Get running docker containers
# Get docker container names
docker ps --format "{{.Names}}"
# Stop all running containers
docker stop $(docker ps -aq)
@jorgeas80
jorgeas80 / install_docker_ubuntu_1910.sh
Created November 16, 2019 12:33
Script to install docker in ubuntu 19.10
#!/bin/sh
CONTAINERD_VERSION="1.2.10-3"
DOCKER_CE_CLI_VERSION="19.03.3~3-0"
DOCKER_CE_VERSION="19.03.3~3-0"
echo "# DOWNLOAD THE DOCKER FILES"
wget "https://download.docker.com/linux/ubuntu/dists/disco/pool/stable/amd64/containerd.io_"$CONTAINERD_VERSION"_amd64.deb"
wget "https://download.docker.com/linux/ubuntu/dists/disco/pool/stable/amd64/docker-ce-cli_"$DOCKER_CE_CLI_VERSION"~ubuntu-disco_amd64.deb"
wget "https://download.docker.com/linux/ubuntu/dists/disco/pool/stable/amd64/docker-ce_"$DOCKER_CE_VERSION"~ubuntu-disco_amd64.deb"
@jorgeas80
jorgeas80 / zshrc
Created November 5, 2019 21:59
My ~/.zshrc config file
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
# Path to your oh-my-zsh installation.
export ZSH="/Users/jorgearevalo/.oh-my-zsh"
# Set name of the theme to load --- if set to "random", it will
# load a random theme each time oh-my-zsh is loaded, in which case,
# to know which specific one was loaded, run: echo $RANDOM_THEME
# See https://github.com/robbyrussell/oh-my-zsh/wiki/Themes
@jorgeas80
jorgeas80 / vimrc
Created November 5, 2019 21:58
My ~/.vimrc config file
set nocompatible
filetype off
filetype indent plugin on
" Buffers
nnoremap gp :bp<CR>
nnoremap gn :bn<CR>
nnoremap gl :ls<CR>
nnoremap gb :ls<CR>:b
@jorgeas80
jorgeas80 / wallabag_delete_duplicates.py
Created February 18, 2019 10:03
Script to delete duplicate entries in your wallabag account
#!/usr/bin/env python
# Requires Python > 3.5.2
import aiohttp
import asyncio
from wallabag_api.wallabag import Wallabag
# If you use wallabag.it this is: https://app.wallabag.it
my_host = 'MY_HOST'