Skip to content

Instantly share code, notes, and snippets.

View sbatururimi's full-sized avatar
:atom:
Farming AI non stop

Stas Batururimi sbatururimi

:atom:
Farming AI non stop
View GitHub Profile
@sbatururimi
sbatururimi / MurmurHash3.py
Created September 10, 2019 13:00
Hash MurmurHash3
def hash_bucket(data, num_buckets=NUMBER_BUCKETS, seed=42):
"""MurmurHash3 was written by Austin Appleby, and is placed in the
public domain. The author hereby disclaims copyright to this source
code."""
c1 = 0xcc9e2d51
c2 = 0x1b873593
length = len(data)
h1 = seed
@sbatururimi
sbatururimi / geo_interface.rst
Created September 6, 2019 06:45 — forked from sgillies/geo_interface.rst
A Python Protocol for Geospatial Data

Author: Sean Gillies Version: 1.0

Abstract

This document describes a GeoJSON-like protocol for geo-spatial (GIS) vector data.

Introduction

@sbatururimi
sbatururimi / convert-geojson-to-wkt.py
Created September 6, 2019 06:41 — forked from drmalex07/convert-geojson-to-wkt.py
Convert GeoJSON to/from WKT in Python. #python #geojson #geometry
import json
import geojson
from shapely.geometry import shape
o = {
"coordinates": [[[23.314208, 37.768469], [24.039306, 37.768469], [24.039306, 38.214372], [23.314208, 38.214372], [23.314208, 37.768469]]],
"type": "Polygon"
}
s = json.dumps(o)
@sbatururimi
sbatururimi / bucketizer.py
Last active July 16, 2019 09:33
Very fast hashing, murmur3+limit to wanted number of bucket(check the last line)
NUMBER_BUCKETS = 600
def hash_bucket(data, num_buckets=NUMBER_BUCKETS, seed=42):
"""MurmurHash3 was written by Austin Appleby, and is placed in the
public domain. The author hereby disclaims copyright to this source
code."""
c1 = 0xcc9e2d51
c2 = 0x1b873593
@sbatururimi
sbatururimi / Data_augmentation_keras_opencv_brightness_hsv.py
Created July 10, 2019 15:09 — forked from avsthiago/Data_augmentation_keras_opencv_brightness_hsv.py
Data augmentation using Keras ImageDataGenerator and OpenCV. Also with brightness augmentation.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Mar 29 09:57:55 2018
@author: avsthiago
"""
from keras.preprocessing.image import ImageDataGenerator
import numpy as np
@sbatururimi
sbatururimi / jupyter_snippets.py
Last active July 7, 2020 07:30
Snippets for Jupyter: autotime+notifications $(jupyter --data-dir)/nbextensions/snippets/snippets.json
{
"snippets" : [
{
"name" : "timing-notifications",
"code": [
"%load_ext autoreload",
"%load_ext jupyternotify",
"%load_ext autotime"
]
}
@sbatururimi
sbatururimi / docker_terminal_size.txt
Last active June 26, 2019 14:51
Docker resize of terminal window
docker exec -it container_name /bin/bash -c "export COLUMNS=`tput cols`; export LINES=`tput lines`; exec bash"
@sbatururimi
sbatururimi / memory_check.py
Last active March 13, 2020 11:47
Checking memory in Jupyter notebook
def show_mem_usage():
'''Displays memory usage from inspection
of global variables in this notebook'''
gl = sys._getframe(1).f_globals
vars= {}
for k,v in list(gl.items()):
# for pandas dataframes
if hasattr(v, 'memory_usage'):
mem = v.memory_usage(deep=True)
if not np.isscalar(mem):
set nocompatible " required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
@sbatururimi
sbatururimi / tmux.md
Created May 23, 2019 06:08 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a