Skip to content

Instantly share code, notes, and snippets.

View julian-amaya's full-sized avatar

Julian Amaya julian-amaya

View GitHub Profile
@julian-amaya
julian-amaya / intersect.js
Created February 27, 2012 19:25
Array intersect in javascript
Array.prototype.intersect =
function() {
if (!arguments.length)
return [];
var a1 = this;
var a = null;
var res = []
var n = 0;
var b = {};
for(var i =0; i<a1.length;i++){
@julian-amaya
julian-amaya / mes.py
Created May 2, 2012 22:04
el dia en el mes pasado
from datetime import date, timedelta
hoy = date.today()
if hoy.month == 1:
min_prev_invoice_date = hoy - timedelta(days=31)
else:
try:
min_prev_invoice_date = hoy.replace(month=hoy.month-1)
except:
min_prev_invoice_date = hoy.replace(day=1)
@julian-amaya
julian-amaya / example.xml
Created May 28, 2012 19:58
Ejemplo API nuevo
<dsProductosSeleccionados>
<Pedido>
<Nota>
salsa teriyaki extra y wasabi, es solo para 2 personas pero safari no sirve bien para pedir esto
</Nota>
<NumPersonas>4</NumPersonas>
<PedidoID>9045</PedidoID>
<direccion>carrera 10 numero 93b 53 apto 302</direccion>
<nombre>victor castillo</nombre>
<telefono>6353162</telefono>
[
{
nombre: 'Ruta1',
puntos: [
{
lat: 0,
long: 0
},
{
lat: 0,
.----------------. .----------------. .-----------------. .----------------. .----------------. .----------------.
| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |
| | ____ ____ | || | ____ | || | ____ _____ | || | ____ | || | ___ ____ | || | _____ _____ | |
| ||_ \ / _|| || | .' `. | || ||_ \|_ _| | || | .' `. | || | |_ ||_ _| | || ||_ _||_ _|| |
| | | \/ | | || | / .--. \ | || | | \ | | | || | / .--. \ | || | | |_/ / | || | | | | | | |
| | | |\ /| | | || | | | | | | || | | |\ \| | | || | | | | | | || | | __'. | || | | ' ' | | |
| | _| |_\/_| |_ | || | \ `--' / | || | _| |_\ |_ | || | \ `--' / | || | _| | \ \_ | || | \ `--' / | |
| ||_____||_____|| || | `.____.' | || ||_____|\____| | || | `.____.' | || | |____||____| | || | `.__.' | |
| | | || | | || |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os, sys
# sys.path+=[os.path.split(os.path.split(os.path.abspath(__file__))[0])[0]]
os.environ['DJANGO_SETTINGS_MODULE']='settings'
from django.core.management import execute_manager
from django.db import transaction
import imp
try:
@julian-amaya
julian-amaya / clean_utf8.py
Last active December 19, 2015 06:19
clean_utf8.py
def convert_to_utf8(filename):
# gather the encodings you think that the file may be
# encoded inside a tuple
encodings = ('windows-1253', 'iso-8859-7', 'macgreek')
# try to open the file and exit if some IOError occurs
try:
f = open(filename, 'r').read()
except Exception:
sys.exit(1)