This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) && { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@property | |
def proxy(self): | |
with open('proxies.txt') as proxy_file: | |
return choice(proxy_file.readlines()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo -e '\nmysql soft nofile 100000\bmysql hard nofile 200000' >> /etc/security/limits.conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |