Skip to content

Instantly share code, notes, and snippets.

View ikks's full-sized avatar

Igor Támara ikks

View GitHub Profile
@ikks
ikks / aq-canairio-screenshot.png
Created May 18, 2019 05:11
Taking screenshots from IBOCA and IQCN
#!/bin/bash
# This script grabs a screenshot both from aiqcn and iboca in order to make a daily snapshot of the service
# Feel free to suggest improvements, or clone it and make it happen in your own server
# thanks to the kind service in the free tier provided by https://api.browshot.com
# No warranties and make sure you get people to know that we should be able to see what are we breathing
curl -L "https://api.browshot.com/api/v1/simple?url=https://aqicn.org/map/bogota/&key=$BROWSHOT_KEY" -o $PATH_PUBLIC_CANAIRIO/canairio-$(TZ='America/Bogota' date +"%Y%m%d%H%M%S")-aiqcn.png
curl -L "https://api.browshot.com/api/v1/simple?url=http://iboca.ambientebogota.gov.co/mapa&key=$BROWSHOT_KEY" -o $PATH_PUBLIC_CANAIRIO/canairio-$(TZ='America/Bogota' date +"%Y%m%d%H%M%S")-iboca.png
@ikks
ikks / entities_to_raw.sql
Created August 11, 2014 13:16
Update html entities to raw in postgresql
UPDATE cms_base_page SET content=replace(content, 'Á', 'Á');
UPDATE cms_base_page SET content=replace(content, 'É', 'É');
UPDATE cms_base_page SET content=replace(content, 'Í', 'Í');
UPDATE cms_base_page SET content=replace(content, 'Ó', 'Ó');
UPDATE cms_base_page SET content=replace(content, 'Ú', 'Ú');
UPDATE cms_base_page SET content=replace(content, 'Ü', 'Ü');
UPDATE cms_base_page SET content=replace(content, 'Ñ', 'Ñ');
UPDATE cms_base_page SET content=replace(content, 'á', 'á');
UPDATE cms_base_page SET content=replace(content, 'é', 'é');
UPDATE cms_base_page SET content=replace(content, 'í', 'í');
#!/bin/bash
if ! grep 205 /etc/resolv.conf; then
sed -i '1s;^;nameserver 192.168.1.205\n;' /etc/resolv.conf
fi
@ikks
ikks / createopenvpncertificate.sh
Created March 28, 2016 14:28
Unified OpenVPN certificate for clients
#!/bin/bash
# Creates a file for clients, just put the name of the cert and answer y to every question
# Based on https://www.digitalocean.com/community/tutorials/how-to-set-up-an-openvpn-server-on-debian-8
if [ $# -ne 1 ]; then
echo $'Make sure you put a name for your new client i.e.:\n'
echo " $0 loginandroid"
echo $''
exit 1
fi
@ikks
ikks / payu_helper.py
Created April 1, 2015 19:49
Payu Helpers for python 2.x .
import hashlib
def payu_rounder(value):
u"""value is a unicode, returns the round according to Payu documentation
to be used by confirmationUrl
>>> payu_rounder(u'150.25')
u'150.2'
>>> payu_rounder(u'150.35')
u'150.4'
>>> payu_rounder(u'150.34')
@ikks
ikks / ShipServiceFedex.py
Created March 12, 2015 15:20
Consuming ShipServiceFedex By Hand in Python
import time
import httplib
from datetime import datetime
from collections import OrderedDict
from django.conf import settings
from constance import config
# You can use soap_call(prepare_data())
@ikks
ikks / gist:3776116
Created September 24, 2012 14:05
annotate with a relation
CartSale.objects.annotate(Count('products'),Sum('products__quantity'))
@ikks
ikks / gist:3775963
Created September 24, 2012 13:31
Django ORM Aggregation samples
#Para contar la cantidad de ventas que se han efectuado:
Cartsale.objects.count()
#Para contar el precio promedio del valor de los artículos vendidos:
CartProduct.objects.aggregate(Avg('price'))
#Para obtener la cantidad de productos que se han vendido:
CartProduct.objects.aggregate(Sum('quantity'))
#Para obtener la cantidad de compras registradas a nombre de un mismo correo:
@ikks
ikks / gist:3775774
Created September 24, 2012 12:45
Cart Sale Model Sample
class CartSale(models.Model):
first_name = models.CharField(
max_length=100,
)
last_name = models.CharField(
max_length=100,
)
date_sale = models.DateTimeField(
auto_now_add=True,
)
@ikks
ikks / gist:3497909
Created August 28, 2012 13:21
Sample of autocomplete_light_registry.py
import autocomplete_light
from cities_light.models import City
autocomplete_light.register(City, search_fields=('search_names',),
autocomplete_js_attributes={'placeholder': 'city name ..'})