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 / music-format-convert.sh
Created February 17, 2017 21:54
Convertir archivos de música a otro formato
#!/bin/sh
for f1 in *.wma;
do
f2=`echo $f1 | cut -d '.' -f 1`.mp3;
avconv -i "$f1" "$f2";
done
@junquera
junquera / filter.js
Last active January 30, 2017 19:08
Print git log in json format
/**
* Bunch of useful filters for angularJS(with no external dependencies!)
* @version v0.5.15 - 2017-01-17 * @link https://github.com/a8m/angular-filter
* @author Ariel Mashraki <[email protected]>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/!function(a,b,c){"use strict";function d(a){return E(a)?a:Object.keys(a).map(function(b){return a[b]})}function e(a){return null===a}function f(a,b){var d=Object.keys(a);return d.map(function(d){return b[d]!==c&&b[d]==a[d]}).indexOf(!1)==-1}function g(a,b){function c(a,b,c){for(var d=0;b+d<=a.length;){if(a.charAt(b+d)==c)return d;d++}return-1}for(var d=0,e=0;e<=b.length;e++){var f=c(a,d,b.charAt(e));if(f==-1)return!1;d+=f+1}return!0}function h(a,b,c){var d=0;return a.filter(function(a){var e=y(c)?d<b&&c(a):d<b;return d=e?d+1:d,e})}function i(a,b){return Math.round(a*Math.pow(10,b))/Math.pow(10,b)}function j(a,b,c){b=b||[];var d=Object.keys(a);return d.forEach(function(d){if(D(a[d])&&!E(a[d])){var e=c?c+"."+d:c;j(a[d],b,e||d)}else{var f=c?c+".
@junquera
junquera / pem2p12.sh
Created January 18, 2017 18:57
Transform a .pem certificate into a java keystore
openssl pkcs12 -export -in fullchain.pem -inkey privkey.pem -out keystore.p12 -name tomcat;
@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
@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);
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 / 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
@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
inotifywait -m -e modify -e create --format '%w%f' . | while read file; do (cp "$file" ./tmp/"$file$(date +%T)$counter.bk") done
@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