Skip to content

Instantly share code, notes, and snippets.

View XayOn's full-sized avatar
🐍

David Francos XayOn

🐍
View GitHub Profile
@XayOn
XayOn / gist:4027564
Created November 6, 2012 21:09
Print a file as a qr code animation in firefox
# QR code generation library by http://code.google.com/p/jsqrencode/ GPL3
# This code is GPL3 as well by David Francos Cuartero (XayOn)
{ cat <<EOF
<!DOCTYPE html><html><head><meta name="apple-touch-fullscreen" content="yes" /><style type="text/css">html { width:100%; height: 100% } body { width:100%; height: 100%; margin: 0px; padding: 0px } div#qrdiv {width:200px; height:200px} </style><script type="text/javascript">adelta=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28];vpat=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177];fmtword=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107];eccblocks=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,2
@XayOn
XayOn / weather_segment.bash
Last active December 11, 2015 11:28
tmux-powerline weather segment written in bash
#!/bin/bash
declare -A tp_weather
tmp_tmp=$(mktemp -d);
tp_weather=(
[location]="779063"
[unit]="c"
[tmp]="${tp_tmp}/weather"
[update_secs]=600
);
(( $(( $(date "+%s") - $(stat -c "%Y" ${tp_weather[tmp]}) )) > 100)) && {
@XayOn
XayOn / random_proxy.py
Created July 1, 2013 08:53
Export a proxy property on a class wich gets a random proxy from a proxies.txt file.
@property
def proxy(self):
with open('proxies.txt') as proxy_file:
return choice(proxy_file.readlines())
@XayOn
XayOn / setup_anon_scrapper.py
Created July 1, 2013 08:56
Get a almost completly anonymous and transparent scrapper
def setup_anonymous_scrapper(self):
self.browser = mechanize.Browser()
self.browser.set_handle_robots(False)
self.browser.set_handle_refresh(False)
self.browser.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
self.browser.set_proxies({"http": self.proxy })
self.data = self.browser.open(self.url).read()
@XayOn
XayOn / Stealth_ scrapper.py
Last active December 19, 2015 16:18
Better scrappery script
import sys
import mechanize
from random import choice
class Scrapper(object):
"""
Main scrapper object.
Use self.do_anonymous_scrapping after setting self.url
(or use scrap() function)
@XayOn
XayOn / Pdf_processor.sh
Created July 12, 2013 08:10
parallel processing PDF files using a specified number of paralellized processes.
tmp=`mktemp`;
[[ $2 ]] && {
while read filename; do pdf2txt "${filename}" -o "${filename}.txt"; done <"$2"
} || {
find . -name "*pdf" -print > $tmp;
nlineas=$(( $(wc -l < $tmp) / $1 ))
for i in $(seq 0 $nlineas); do
[[ $i == $nlineas ]] && {
tail -n+$(( $i * $1 )) $tmp > ${tmp}_${i}
@XayOn
XayOn / mysql_checker.sh
Created July 17, 2013 06:59
mysl checker
#!/bin/bash
# This is for clarity on this example, usually for this I'd use directly $1 $2 $3 in the mysql call
user=$1;
pass=$2;
host=$3;
echo "select * from users limit 1" | mysql -u$user -p$pass $db || {
mail -s "El servidor mysql se ha caido" me@davidfrancos.net <<< "Mysql ha fallado a fecha `date`"
echo "show processlist" | mysql -u$user -p$pass $db > /var/log/mysql_ps_crashlog_`date +%m-%d-%y_%H_%M`.log
}
@XayOn
XayOn / mysql-large.sh
Created July 17, 2013 07:22
Put mysql large default config on debian and derivatives
zcat /usr/share/doc/mysql-server-5.5/examples/my-large.cnf.gz > /etc/mysql/my.cnf
# Now, edit the file and in [mysql] section, put:
user = mysql
# And restart the server
service mysql restart
@XayOn
XayOn / security_limits.sh
Created July 17, 2013 07:48
security limits
echo -e '\nmysql soft nofile 100000\bmysql hard nofile 200000' >> /etc/security/limits.conf
@XayOn
XayOn / install_vim_experimental.sh
Created July 19, 2013 07:23
Install experimental vim
echo "deb http://ftp.fr.debian.org/debian/ experimental main contrib non-free" > /etc/apt/sources.list.d/experimental.conf"
apt-get update
apt-get install -texperimental vim