Skip to content

Instantly share code, notes, and snippets.

@juanescalona
juanescalona / dnipe.py
Last active June 22, 2022 19:05
Clase para validar, calcular dígito verificador y generar DNIs de Perú
from random import randint
class DniPeru:
def __init__(self):
self.numbers = (6, 7, 8, 9, 0, 1, 1, 2, 3, 4, 5)
self.letters = ('K', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J')
self.multiples = (3, 2, 7, 6, 5, 4, 3, 2)
def __index(self, dni):
@korakot
korakot / sheet_df.py
Last active March 29, 2024 23:33
Save dataframe to Google Sheet from Colab
# authenticate
from google.colab import auth
auth.authenticate_user()
import gspread
from oauth2client.client import GoogleCredentials as GC
gc = gspread.authorize(GC.get_application_default())
# create, and save df
from gspread_dataframe import set_with_dataframe
title = 'New Sheet'
gc.create(title) # if not exist
@radutzan
radutzan / Transantiago public endpoints.md
Last active October 13, 2023 03:31
APIs REST públicas con data del Transantiago. Respuestas en JSON.

Nuevo: SCLTransit

Ignacio Hermosilla implementó un servicio web de acceso público usando los feeds GTFS de Transantiago y los puntos de acceso oficiales que normalmente requieren acuerdos con el DTPM, para que tú no tengas que hacerlo.

Está toda la información de Transantiago que puedas necesitar, con formatos de alta calidad y sin trámites. Estas APIs son las que ahora alimentan a Cromi.

APIs internas de Transantiago (no recomendadas)

Transantiago implementó estas APIs para uso interno, por lo que no hay ninguna garantía sobre su funcionalidad, mantenimiento o futura existencia. Úsalas bajo tu propio riesgo. (Probablemente no es aconsejable que las uses para nada crítico.)

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Written as part of https://www.scrapehero.com/how-to-scrape-amazon-product-reviews-using-python/
from lxml import html
import json
import requests
import json,re
from dateutil import parser as dateparser
from time import sleep
# Descargar archivos.xml desde http://www.servel.com/archivos.xml
import xml.etree.ElementTree as ET
import urllib2, os, sys
def progress(nregion, comuna, download, response, chunk_size=8192, report_hook=None):
total_size = float(response.headers["Content-Length"])
bytes_size = 0.0
data = []
while 1:
@Experiment5X
Experiment5X / Student.cpp
Created January 5, 2014 22:45
Just a simple project I made to demonstrate some concepts in C++. Here's the video where I teach this project: http://www.youtube.com/watch?v=NIoEVxe-rpk
//
// Student.cpp
// StudentInformationAnalyzer
//
// Created by Adam Spindler on 1/4/14.
// Copyright (c) 2014 Adam Spindler. All rights reserved.
//
#include "Student.h"
@cincodenada
cincodenada / rot.py
Created September 14, 2013 00:09
Quick binary rotation (rotl/rotr) in Python
def rotl(num, bits):
bit = num & (1 << (bits-1))
num <<= 1
if(bit):
num |= 1
num &= (2**bits-1)
return num
def rotr(num, bits):