Skip to content

Instantly share code, notes, and snippets.

import pandas as pd
import time
from datetime import date
import pathlib
class Series(object):
def __init__(self, name, schema, start, end, freq, top=0, use_cache=False, flag=False):
self.df = None = name
gallir /
Created Apr 3, 2021
covid prediction with fbprophet
#! /usr/bin/env python3
import pandas as pd
import pycountry
from datetime import date, timedelta
from fbprophet import Prophet
from concurrent.futures import ProcessPoolExecutor
from .base import Series
gallir /
Last active Dec 25, 2021
A basic pipeline for AWS Forecast
from botocore.hooks import _PrefixTrie
import util
import boto3
from .s3utils import upload_csv
import time
import pprint
class Pipeline:
def __init__(self, name, target, freq, horizon, s3_bucket, related=None, domain="RETAIL",
gallir /
Last active Apr 12, 2020
Very fast function to get cosine similarity between 2 short texts, where counting the number of words is no needed (i.e. binary bag of words) but it works pretty well with non-ascii weird characters.
from unidecode import unidecode
import re
import sys
import inflection
import numpy as np
import math
from collections import defaultdict
# Using cosine_similarity, own faster implementation, inspired by
gallir / actor.go
Created Aug 20, 2016
an actor in go
View actor.go
package main
import "fmt"
var (
requestToActor chan int
responseFromActor chan int
const (
gallir / cpuidle.go
Last active Aug 2, 2016
cpu idle updaters
View cpuidle.go
func (broker *Broker) updateCPUIdle() {
select {
case broker.cpuUpdateChannel <- true:
func (broker *Broker) cpuIdleUpdater() {
// Initial values required to get stats
minPeriod := 20 * time.Millisecond
gallir / cache.go
Created Aug 2, 2016
A time serie cache
View cache.go
package main
import (
type SerieElement struct {
ts time.Time
data *BookingData
View gist:05be611db38c6beec310
func (soc *Socket) sendMessage(dontwait Flag, parts ...interface{}) (total int, err error) {
// TODO: make this faster
// Done, ;)
var partial int
// Pop the last empty slices
for i := len(parts) - 1; i >= 0; i-- {
switch tLast := parts[i].(type) {
case []string:
gallir /
Created Dec 28, 2015
Como pero el sesgo de cada persona cambia con cada elección
#! /usr/bin/env python
import numpy.random as npr