Skip to content

Instantly share code, notes, and snippets.

@miltonlab
miltonlab / insert_mdb_mssql.py
Last active April 14, 2018 11:10
Set record read from Access to insert into SQLServer
import decimal
from decimal import Decimal
import datetime
#Read from Microsoft Access
#rows = cursor_access.execute("SELECT * FROM Predios")
#One record example:
row = (98, '11', '04', '57', '01', '01', '004', '005', '000', '00', '000', '1104570101004005', 'EDIFICADO', 'TNTE MAXIMILIANO RODRIGUEZ', 'UNIPROPIEDAD', 'Residencial', 'C:\\FOTOS\\570101\\004\\005.jpg', 'MODESTO BURNEO', 'S/N', 'JACINTA REYES', 'LOJA, SAN SEBASTIAN', 'Natural', None, datetime.datetime(1973, 1, 26, 0, 0), 44, 'Femenino', False, 'CARMEN PAULINA', 'ILLESCAS BURNEO', 'Cédula', '1102962741', '-', '-', 'Casado', 'MANUEL AGUSTIN', 'TOLEDO CUEVA', 'Cédula', '-', '-', '-', 'BURNEO CAMPOVERDE JULIO MARIANA', '-', None, None, None, None, None, None, None, 'Cédula', None, None, None, False, True, 'Loja', 'Celica', '3', datetime.datetime(2011, 10, 7, 0, 0), '254', datetime.datetime(2011, 10, 31, 0, 0), False, 0, 0, 'Compra - venta', True, 'Calle', 'Adoquín de cemento', True, True, True, True, False, True, True, True, False, True, False, False,
# List branches for remote repositorie
git ls-remote --heads https://github.com/jquemada/cal_branches
import urllib.request
import json
def analisa_detalhe(cod):
url = 'http://educacao.dadosabertosbr.com/api/escola/'
resp = urllib.request.urlopen(url+str(cod)).read()
resp = json.loads(resp.decode('utf-8'))
if int(resp['salasExistentes']) > 1:
print ('Salas Existentes:', resp['salasExistentes'])
print ('Funcionários:', resp['funcionarios'])
@miltonlab
miltonlab / matrcies.py
Last active August 29, 2015 14:20
Matrices
from numpy import array
a = array([[5.1, 7.4, 3.2, 9.9],
[1.9, 6.8, 4.1, 2.3],
[2.9, 6.4, 4.3, 1.4]])
#cantidad de elemtos
a.size
#dimensiones
a.shape
#Lectura: Obtener un elemento contenido en la matriz
a[1, 3]
@miltonlab
miltonlab / operaciones_arreglos-.py
Created May 4, 2015 14:23
Operaciones con arreglos en Python
edades = numpy.array[(20,23,22)]
#lectura
print (edades[2])
#escritura
edades[1] = 27
#presentacion
for i in range(0, len(edades)):
print (edades[i])
#aunque en python no hace falta el bucle
print(edades)
@miltonlab
miltonlab / manejo_arreglos.py
Created May 4, 2015 14:13
Manejo de Arreglos en Python
import numpy
#creacion e inicializacion
a = numpy.array([2,4,5,9])
#creacion
b = numpy.array()
#inicializacion, por defecto el tipo de dato usado es float
b = numpy.empty(4)
#Mas formas de inicializacion
dias = numpy.empty(7)
edades = numpy.empty(20, dtype=int)
#!/usr/bin/env python
"""
=====================================
PEP 20 (The Zen of Python) by example
=====================================
Usage: %prog
:Author: Hunter Blanks, hblanks@artifex.org / hblanks@monetate.com
@miltonlab
miltonlab / test_ips.sh
Created December 11, 2014 17:29
Verify conection to certain IPs range
echo "" > /tmp/bads.txt
inicio=164
fin=165
for i in `seq $inicio $fin`
do
ip=10.10.$i.1
if ping $ip -w2 | grep "0 received"
then
echo $ip >> /tmp/bads.txt
fi
@miltonlab
miltonlab / tips.R
Last active August 29, 2015 14:08
Tips and Notes about coding with R
## dplyr package notes
# dplyr use plyr and haver relation with data.table
library(dplyr)
# Example
ddply(df, ~date, summarise, totalSteps=sum(steps))
## *Complete dni ecuatorian numbers with '0'. If length == 9
## Sometimes usefull when Spreadsheet cut that number at start
# =========================================================================================
> head(reporte)
@miltonlab
miltonlab / gnu.sh
Last active August 29, 2015 14:04
Gnu / Linux scripts
# ---------------------------------------------------
# Update LinuxMint to v17
# ---------------------------------------------------
sudo sed -i 's/raring/trusty/' /etc/apt/sources.list
sudo sed -i 's/olivia/qiana/' /etc/apt/sources.list
sudo sed -i 's/raring/trusty/' /etc/apt/sources.list.d/official-package-repositories.list
sudo sed -i 's/olivia/qiana/' /etc/apt/sources.list.d/official-package-repositories.list
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get upgrade