Skip to content

Instantly share code, notes, and snippets.

View brandomr's full-sized avatar

Brandon Rose brandomr

View GitHub Profile
@brandomr
brandomr / data_profiling.py
Created July 13, 2023 13:54
MIT data profiling to TDS
import io
import pandas
import requests
import json
##########################
# generate dataset metadata
# I assume this will come from the HMI during user upload
##########################
dataset = {
@brandomr
brandomr / es-mapping-update.py
Created November 21, 2022 19:32
es-mapping-update
from elasticsearch import Elasticsearch
import json
es = Elasticsearch('http://localhost:9200')
q = {
"query": {
"match_all": {}
}
}
date EthiopiaArrivals Itoobiya qaxooti UN abaar shaqada Oromiya gargaar skype
2017-02-28 9834 5.5 4.0 17.75 0.0 4.25 2.25 0.0 19.25
2017-03-31 20515 8.5 3.0 27.0 2.5 5.0 0.0 0.0 21.0
2017-04-30 10797 8.0 0.0 20.0 0.8 5.6 0.0 3.2 13.2
2017-05-31 4876 6.5 1.25 16.75 2.5 3.5 2.5 0.0 14.0
2017-06-30 6184 3.5 1.25 17.0 0.0 2.5 0.0 2.5 14.75
2017-07-31 3311 3.4 0.0 22.8 0.0 1.4 3.0 0.0 18.6
2017-08-31 9288 7.5 0.0 21.25 0.0 3.25 2.25 2.25 21.0
2017-09-30 27144 12.75 1.5 33.25 0.0 2.25 13.0 3.25 25.25
2017-10-31 3229 12.2 0.0 25.2 0.0 6.0 2.4 0.0 15.2
openapi: 3.0.0
info:
title: "World Modelers Search API"
description: "This API specification is for the World Modelers search."
version: "1.0.0"
paths:
/search:
post:
tags:
@brandomr
brandomr / gemini.py
Created December 26, 2017 20:34
Class for interacting with Gemini API
class gemini(object):
"""
An object for interacting with the Gemini API. Full Gemini API documentation is
available at https://docs.gemini.com
"""
def __init__(self, gemini_api_key, gemini_api_secret, base_url):
"""
Initializes gemini object.
from datetime import datetime
import requests
import json
def find_traffic_time(dt):
epoch = datetime(1970,1,1)
delta_time = (dt - epoch).total_seconds()
epoch_t = str(delta_time).split('.')[0]
# build query
@brandomr
brandomr / merkle_tree.py
Created December 6, 2016 02:01
implement merkle tree in python
from hashlib import sha256 as sha
def chunks(l, n):
"""Yield successive n-sized chunks from l."""
for i in range(0, len(l), n):
yield l[i:i + n]
def m_tree(transactions):
"""Takes an array of transactions and computes a Merkle root"""
sub_t = []
@brandomr
brandomr / email_2_name.py
Last active August 14, 2016 17:13
A email to name matching script
from fuzzywuzzy import process
names = ['Megan Sherman','Jin Zhang','Amr Ahmed','Jeffrey De Fauw','Linus Upson','Jonathan Binghman']
emails = ['jon.bingham@gmail.com','megansherman@google.com','jbingham@google.com','jinzhang@google.com','linus@google.com']
names_cleaned = [i.lower() for i in names]
emails_cleaned = [i.split('@')[0] for i in emails]
for email in emails_cleaned:
print '######'
def treat_number(i):
i = str(i)
i = i.replace('+','')
i = i.replace('-','')
#i = int(i)
if i[0] == '1' and len(i) == 11:
i = i[1:11]
return i