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
@schcriher
schcriher / Ecuaciones.py
Last active December 27, 2015 20:49
Envoltura de scipy.optimize.fsolve para sistemas de ecuaciones mas "idiomáticas"
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#
# Copyright (C) 2013 Cristian Hernán Schmidt <schcriher@gmail.com>
#
# Ecuaciones.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.
#
@schcriher
schcriher / delete_nppdf32Log.py
Created November 9, 2013 17:48
Parche para al archivo "nppdf.so"
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
#
# Copyright (C) 2013 Cristian Hernán Schmidt <schcriher@gmail.com>
#
# delete_nppdf32Log.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.
#
@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.
#
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;
"""
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"
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)+' ';
@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
@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 / 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 / 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