Skip to content

Instantly share code, notes, and snippets.

View junquera's full-sized avatar
🐈‍⬛

Javier JUNQUERA SÁNCHEZ junquera

🐈‍⬛
View GitHub Profile
@junquera
junquera / devToolsWatcher.js
Last active April 5, 2016 22:06
Developer Tools Watcher (just tested in Google Chrome)
function devToolsOpened(){
return window.outerHeight - window.innerHeight > 100;
}
function devToolsWatcher(){
console.log(devToolsOpened());
}
setInterval(devToolsWatcher, 1000);
@junquera
junquera / changeNames.sh
Last active May 16, 2016 13:02
Change file names with number format. Example: [1.html; 2.html; 3.html] -> [001.html; 002.html; 003.html]
for f in *.html; do
[[ $f =~ ([0-9]+).html ]]
mv "$f" $(printf "%03d.html" ${BASH_REMATCH[1]})
done
@junquera
junquera / dockerClean.sh
Created April 12, 2016 09:35
Deletes all stoped docker containers. From [Raspberry Pi Forums](https://www.raspberrypi.org/forums/viewtopic.php?t=37222&p=310459)
docker rm `docker ps -a | grep Exited | awk '{print $1 }'`
docker rmi `docker images -aq`
@junquera
junquera / primos.py
Last active May 9, 2016 08:50
Números primos con lambdas en python.
from math import sqrt
def primosHasta(n):
numbers = range(2, n)
for i in range(2, int(2*sqrt(n))):
numbers = filter(lambda x: x==i or x%i, numbers)
return numbers
inotifywait -m -e modify -e create --format '%w%f' . | while read file; do (cp "$file" ./tmp/"$file$(date +%T)$counter.bk") done
@junquera
junquera / thumbnailer.sh
Created May 16, 2016 13:00
Generate a file thumbnail
#!/bin/bash
oFilename=$(basename "$1")
extension="${oFilename##*.}"
filename="${oFilename%.*}"
if [ "$extension" == "pdf" ]; then
convert -thumbnail 300 "$oFilename"[0] "$filename".thumb.png
else
convert -thumbnail 300 "$oFilename" "$filename".thumb.png
fi
@junquera
junquera / psub.pl
Created August 9, 2016 07:14
Substitute tag with file
# Example perl -pe 's/{css}/`cat stylesheet.css`/ge' -i index.html
perl -pe 's/{tag}/`cat file.from`/ge' -i file.to
import hashlib
import time
def genToken(password):
h = hashlib.sha1(password)
h.update(str(int(time.time()*1000)))
return h.hexdigest()
def isValid(password, token):
t = int(time.time()*1000)
for i in range(5000):
@junquera
junquera / pacman-follow-pointer.html
Created December 17, 2016 18:53
Pacman following your pointer
<html style="cursor: none">
<script>
var x = 0;
var y = 0;
document.addEventListener("mousemove", function(e){
document.getElementById("pacman").style.left = e.x;
document.getElementById("pacman").style.top = e.y;
console.log("x ", x, "; y ", y);
@junquera
junquera / split_flac.sh
Created January 16, 2017 19:45
Split flac file into song files
# $1 -> cue file
# $2 -> flac file
cuebreakpoints $1 | shnsplit -o flac $2