Skip to content

Instantly share code, notes, and snippets.

🏠
Working from home

Gustavo León Tramontin urkh

🏠
Working from home
Block or report user

Report or block urkh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@urkh
urkh / bulk_upsert.py
Created Apr 17, 2019 — forked from aisayko/bulk_upsert.py
Postgresql bulk upsert in Python (Django)
View bulk_upsert.py
def bulk_upsert(model, fields, values, by):
"""
Return the tuple of (inserted, updated) ids
"""
result = (None, None)
if values:
stmt = """
WITH data_set AS (
INSERT INTO %s (%s)
@urkh
urkh / convert_latin1_utf8.sql
Created Feb 17, 2016
convert latin1 chars to utf8
View convert_latin1_utf8.sql
UPDATE table SET field = CONVERT(CAST(CONVERT(field USING latin1) AS BINARY) USING utf8)
@urkh
urkh / countries.sql
Last active Sep 17, 2015 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
View countries.sql
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
View gist:f28d4e3e3bcb7c804a91
class OCMDBMaintenanceCreate(CreateView):
template_name = 'ocmdb_maintenance/create.html'
form_class = MaintenanceForm
model = OCMDB_MaintenanceCI
success_url = reverse_lazy('ocmdb_maintenance_list')
object = None
def get(self, request, *args, **kwargs):
form_class = self.get_form_class()
View gist:dce101e9a9c2af35c4f9
class OCMDBMaintenanceCreate(CreateView):
template_name = 'ocmdb_maintenance/create.html'
form_class = MaintenanceForm
model = OCMDB_MaintenanceCI
success_url = reverse_lazy('ocmdb_maintenance_list')
object = None
def get(self, request, *args, **kwargs):
form_class = self.get_form_class()
View gist:aae596edfa2e33bc7421
from django.utils import simplejson
from django.http import HttpResponse
class JsonResponse(HttpResponse):
"""
JSON response
"""
def __init__(self, content, mimetype='application/json', status=None, content_type=None):
super(JsonResponse, self).__init__(
content=simplejson.dumps(content),
View splinter config
user_agent = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.118 Safari/537.36"
proxy = {
'network.proxy.type': 1,
'network.proxy.http': ip,
'network.proxy.http_port': port,
'network.proxy.ssl': ip,
'network.proxy.ssl_port': port,
'network.proxy.socks': ip,
'network.proxy.socks_port': port,
@urkh
urkh / pyscde_grados
Created Mar 19, 2015
utilidad para procesar archivos csv
View pyscde_grados
import csv
import sys
# periodo, cedula, carrera(200), materia, seccion(U), nota(EQ)
materias = ['EF3106', 'EF3301', 'EF3305', 'EF2420', 'EF2413', 'EF2415', 'EF2414', 'EF2417', 'EF2419',
'EF2418', 'EF1426', 'EF2404', 'EF2411', 'EF2408', 'EF2416', 'EF3302', 'EF2410', 'EF2403', 'EF3312', 'EF1424']
f = open(sys.argv[1], 'rb')
print sys.argv[1]
print sys.argv[2]
@urkh
urkh / pyscde_grados
Created Mar 19, 2015
utilidad para procesar archivos csv
View pyscde_grados
import csv
import sys
# periodo, cedula, carrera(200), materia, seccion(U), nota(EQ)
materias = ['EF3106', 'EF3301', 'EF3305', 'EF2420', 'EF2413', 'EF2415', 'EF2414', 'EF2417', 'EF2419',
'EF2418', 'EF1426', 'EF2404', 'EF2411', 'EF2408', 'EF2416', 'EF3302', 'EF2410', 'EF2403', 'EF3312', 'EF1424']
f = open(sys.argv[1], 'rb')
print sys.argv[1]
print sys.argv[2]
View compare.py
#!/usr/bin/env python
"""Compare two aligned images of the same size.
Usage: python compare.py first-image second-image
"""
import sys
from scipy.misc import imread
from scipy.linalg import norm
You can’t perform that action at this time.