Skip to content

Instantly share code, notes, and snippets.

Avatar

Hans Roman snahor

  • Wakanda
View GitHub Profile
View gist:294105
# Including logging
log_file = who_args.pop('log_file', None)
if log_file is not None:
if log_file.lower() == 'stdout':
log_stream = sys.stdout
elif log_file.lower() == 'stderr':
log_stream = sys.stderr
else:
log_stream = open(log_file, 'wb')
who_args['log_stream'] = log_stream
View gist:410290
google.pacman ||
function () {
var a = true,
e = false,
g = {},
i = [1, 4, 2, 8],
l = {
0: {
axis: 0,
increment: 0
View number_of_rows_per_table.sql
-- SQL Server
SELECT [Tables] = so.name,
[Rows] = MAX(si.rows)
FROM sysobjects so,
sysindexes si
WHERE so.xtype = 'U'
AND si.id = OBJECT_ID(so.name)
GROUP BY so.name
ORDER BY 2 DESC
View gist:417112
// Connection String to Excel Workbook
string excelConnectionString = @"Provider=Microsoft
.Jet.OLEDB.4.0;Data Source=Book1.xls;Extended
Properties=""Excel 8.0;HDR=YES;""";
// Create Connection to Excel Workbook
using (OleDbConnection connection =
new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand
View gist:452250
REPLACE(SUBSTRING(ci.dir_cliente,
CHARINDEX('->', ci.dir_cliente),
CHARINDEX('->', ci.dir_cliente)), '-> ' ,'')
View gist:474674
#!/usr/bin/env python
#
# A nifty GUI controlling the window controls position
#
# Depends on python-gconf (started from a python-gconf example)
#
# @version 0.1
# @author alex(at)eftimie(dot)ro
#
View jquery.dummyemailbox.js
(function($) {
jQuery.fn.dummyEmailBox = function() {
var domains = [
'gmail.com',
'hotmail.com',
'hotmail.es',
'live.com',
'live.es',
'yahoo.com',
'yahoo.es',
View choices.py
# -*- coding: utf-8 -*-
SI_NO = ((0, u'No'), (1, u'Sí'))
DILUCIONES = (
('1', '1'),
('1:2', '1:2'),
('1:4', '1:4'),
('1:8', '1:8'),
('1:16', '1:16'),
View gist:751869
SELECT
(SELECT name
FROM ubigeo u0
WHERE u0.province_code = ubigeo.province_code
AND u0.department_code = ubigeo.department_code LIMIT 1) AS "provincia",
(SELECT name
FROM ubigeo u0
WHERE u0.department_code = ubigeo.department_code LIMIT 1) AS "departamento",
"ubigeo"."id", "ubigeo"."department_code", "ubigeo"."province_code", "ubigeo"."district_code", "ubigeo"."name" FROM "ubigeo" WHERE "ubigeo"."id" = 758
View edades.py
def edad_gestacional_fur(self):
if self.ultima_menstruacion:
# 40 semanas
days = (date.today() - self.ultima_menstruacion).days
return '{0} {1}/7'.format(days / 7, days % 7)
return None
def edad_gestacional_1eco(self):
"""Retorna la edad gestacional segun la primera ecografia."""
if self.primera_ecografia: