Skip to content

Instantly share code, notes, and snippets.

View schcriher's full-sized avatar
🏠
Working from home

Schmidt Cristian Hernán schcriher

🏠
Working from home
View GitHub Profile
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# Copyright (C) 2023 Schmidt Cristian Hernán
# Este script descarga el histórico de los valores del precio del dólar en la
# República Argentina y los gráfica, agregando además los cambios de presidentes
# que hubieron en el rango de los valores disponibles.
#
# Se almacenan además los datos en un archivo csv y se guarda la imagen en formato
# png y svg. Los tres archivos en la misma carpeta donde donde esté este archivo,
@schcriher
schcriher / jobs_fix.py
Last active February 18, 2020 07:42
Persistence of jobs - PTB
import os
import sys
import pickle
from threading import Thread, Event
from time import time, sleep
from datetime import timedelta
from telegram import Update
from telegram.ext import Updater, Filters, CommandHandler, MessageHandler, Job
@schcriher
schcriher / checkio-break-rings.py
Created November 23, 2017 20:18
How to break enough rings to free so as to get the maximum number of rings possible
# -*- coding: UTF-8 -*-
# https://py.checkio.org/mission/break-rings/
# https://py.checkio.org/mission/break-rings/publications/schcriher/python-3/cute-problem/
# All of the rings are numbered and you are told which of the rings are connected. This
# information is given as a sequence of sets. Each set describes the connected rings.
# For example: {1, 2} means that the 1st and 2nd rings are connected. You should count
# how many rings we need to break to get the maximum of separate rings. Each of the
@schcriher
schcriher / checkio-climbing-route.py
Created November 19, 2017 20:34
You have an elevation map and you want to know the shortest climbing route
# -*- coding: UTF-8 -*-
# https://py.checkio.org/mission/climbing-route/
# https://py.checkio.org/mission/climbing-route/publications/schcriher/python-3/persistence/
# You have an elevation map and you want to know the shortest climbing route.
#
# The map is given as a list of strings.
# - 0 : plain (elevation is 0)
@schcriher
schcriher / git-cloneall
Created May 15, 2017 17:28
Clone a complete repository of github (all branches)
#!/bin/bash
if [[ $# -eq 0 || $# -ge 3 ]];then
echo "git cloneall path/url [folder]"
exit 1
fi
if [ -n "$2" ];then
folder=$2
else
name=${1##*/}
folder=${name%%.git}
@schcriher
schcriher / public-ip-cached
Created May 15, 2017 17:20
Returns public IP, querying a URL every few minutes at most. If the IP is queried very fast, the cached IP is returned
#!/bin/bash
minute=5
cache=/tmp/public-ip-cached
if [[ ! -f $cache || $(echo "$(stat -c %Y $cache) + $minute * 60 < $(date +%s)" | bc) -eq 1 ]];then
wget http://ipinfo.io/ip -qO - > $cache
fi
cat $cache
javascript:Qr=''+document.getSelection();if(!Qr)Qr=prompt('Diccionario de la Real Academia Española.\nTeclee la palabra que desea consultar:','');if(Qr!=null)location='http://dle.rae.es/?w='+encodeURI(Qr)+' ';
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%clip hello world
# will store "hello world"
var xLBD = {};
xLBD.c = function (){
xLBD.f = unescape(document.querySelector("[flashvars]").getAttribute("flashvars")).substring(7);
xLBD.f = JSON.parse(xLBD.f.substring(0, xLBD.f.lastIndexOf("}") + 1)).video_data[0].hd_src;
xLBD.a = "<div style='position:absolute;top:100px;height:300px;left:15%;background:#fff;border:10px solid #000;font-size:5em;padding:100px;'>Click <a download='lookback.mp4' href='"+xLBD.f+"'>here<\/a> to download your lookBack video.</div>";
document.body.innerHTML += xLBD.a;
}
if(document.readyState == "complete")
xLBD.c();
else window.onload = xLBD.c;
@schcriher
schcriher / texdiff.py
Last active November 9, 2017 01:14
Calcula la diferencia entre dos textos
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#
# Copyright (C) 2013-2017 Cristian Hernán Schmidt
#
# texdiff.py is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#