Skip to content

Instantly share code, notes, and snippets.

@Viroide
Viroide / views.py
Created April 21, 2015 12:34
Lo que se encuentra uno por la vida. [HUMOR] [TRUESTORY]
def callbackOK_oferta(request):
user = request.user
reservas = Oferta_reserva.objects.filter(user=user)
for reserva in reservas:
if reserva.estado == 'pendiente':
reserva.estado = 'completado'
reserva.save()
return render_to_response('reserva_pago.html', locals(), context_instance=RequestContext(request))
@Viroide
Viroide / prelodImages
Created September 18, 2015 10:10
To preload a number of backgrounds that are named like "background-*.png"
$.preloadImages = function(cantidad) {
for (var i = 0; i < cantidad; i++) {
$("<img />").attr("src", "/path/background-"+i+".png");
}
}
$.preloadImages(10); //number of backgrounds
@Viroide
Viroide / hour_options.html
Last active September 30, 2015 11:34
How to create hours options with 1 emmet command
<!-- option[value="$$@00"]{$$@00}*24 -->
<option value="00">00</option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
.middle-vertical-align
position relative
top 50%
transform translateY(-50%)
@Viroide
Viroide / utf8PoFixer.py
Created November 25, 2015 11:00
Fix .po files with utf8 problems
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import re
f = sys.argv[1]
with open (f, "rt") as myfile:
s=myfile.read()
@Viroide
Viroide / killOldersJava
Last active December 30, 2015 10:55
Kills older java process that are in the server
killOldersJava(){
javaProcessNumer=`ps -ej | grep java | wc -l`
while [ $javaProcessNumer -gt 1 ]
do
PID=`ps -ej --sort=start_time | grep java | head -n1 | awk '{ print $1 }'`
echo "More than one java process, killing the older PID=$PID"
kill -9 $PID
javaProcessNumer=`ps -ej | grep java | wc -l`
done
PID=`ps -ej --sort=start_time | grep java | head -n1 | awk '{ print $1 }'`
jobs=("job1" "job2" "job3");
for job in ${jobs[@]}; do
curl -s http://USER:TOKEN@URL_TO_JENKINS/job/$job/config.xml > $job.xml
done
@Viroide
Viroide / commas2semicolons.py
Last active April 27, 2016 07:41
Replace semicolons with commas in a CSV
from csv import reader, writer
with open('input.csv') as inp, open('output.csv', 'w') as out:
writer(out, delimiter=';').writerows(reader(inp))
@Viroide
Viroide / verify_apk.sh
Last active May 1, 2016 12:53
verifies that the apk is ready to upload to the store: Nop debug mode and signed correctly
# Start custom variables - Change this variables as you need
ANDROID_VERSION=21.1.2
SSH_SIGN="SHA1: A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1:A1"
# End custom variables
# Start color variables -
GREEN='\033[0;32m'
RED='\033[0;31m'
NC='\033[0m'
# End color variables
@Viroide
Viroide / currentWeek.groovy
Created June 8, 2016 15:46
returns the current week
def private static currentWeek() {
def current = new Date().clearTime()
int currentDay = Calendar.instance.with {
time = current
get(DAY_OF_WEEK)
}
def listOfDays = (current - currentDay + 2)..(current - currentDay + 8)
listOfDays.collect {
"date" : it.format("yyyyMMdd")
}