Skip to content

Instantly share code, notes, and snippets.

View sbatururimi's full-sized avatar

Stas Batururimi sbatururimi

View GitHub Profile
@sbatururimi
sbatururimi / gist:2ab8921ff7e0d205bd44b857dd30a81f
Created October 5, 2023 18:20
problematic_supabase_num_type.md
`amount` is of type: float4
```
import { Pool } from 'https://deno.land/x/postgres@v0.17.0/mod.ts';
export async function getDBPool() {
const POOL_CONNECTIONS = 20;
const dbPool = new Pool(
{
@sbatururimi
sbatururimi / convert.sh
Created August 16, 2022 15:28 — forked from ettingshausen/convert.sh
How to convert mov to mp4 on macOS
brew install ffmpeg
ffmpeg -i /path/to/input/file /path/to/output.mp4
@sbatururimi
sbatururimi / percentiles.py
Created July 10, 2022 14:23
Compute percentiles per group in pandas dataframe
def percentile(n):
def percentile_(x):
return np.percentile(x, n)
percentile_.__name__ = 'percentile_%s' % n
return percentile_
df.groupby(['id'])[cols].agg(['min', 'max', np.mean, np.std, np.median, percentile(50), percentile(95)])
@sbatururimi
sbatururimi / search-git-history.md
Created July 28, 2021 14:09 — forked from lyoshenka/search-git-history.md
Search Git commit history for a string and see the diffs

Searching Git commit history

This should be one of the core features of Git, but for some reason it's impossible to figure out how to search for a string in your commit history and see the diffs that that string is in. Here's the best I've come up with:

To find which commits and which files a string was added or removed in:

git log -S'search string' --oneline --name-status

To see the diff of that

@sbatururimi
sbatururimi / python3_removal.md
Last active August 7, 2021 05:12
Ubuntu Python3 removal/installation

Remove

sudo dpkg  --force-depends --purge  libpython3.9-minimal

Or

sudo dpkg --remove --force-depends python3.6 python3.6-minimal libpython3.6-minimal libpython3.6-stdlib

https://askubuntu.com/a/1069440

@sbatururimi
sbatururimi / building_tensorflow.md
Created November 27, 2020 08:26 — forked from kmhofmann/building_tensorflow.md
Building TensorFlow from source

Building TensorFlow from source (TF 2.3.0, Ubuntu 20.04)

Why build from source?

The official instructions on installing TensorFlow are here: https://www.tensorflow.org/install. If you want to install TensorFlow just using pip, you are running a supported Ubuntu LTS distribution, and you're happy to install the respective tested CUDA versions (which often are outdated), by all means go ahead. A good alternative may be to run a Docker image.

I am usually unhappy with installing what in effect are pre-built binaries. These binaries are often not compatible with the Ubuntu version I am running, the CUDA version that I have installed, and so on. Furthermore, they may be slower than binaries optimized for the target architecture, since certain instructions are not being used (e.g. AVX2, FMA).

So installing TensorFlow from source becomes a necessity. The official instructions on building TensorFlow from source are here: ht

@sbatururimi
sbatururimi / intel-nvidia.md
Created December 14, 2019 15:02 — forked from wangruohui/intel-nvidia.md
Intel for display, Nvidia for computing

Intel for display, NVIDIA for computing

This guide will show you how to use Intel graphics for rendering display and NVIDIA graphics for CUDA computing on Ubuntu 18.04 desktop.

I made this work on an ordinary gaming PC with two graphics devices, an Intel UHD Graphics 630 plus an NVIDIA GeForce GTX 1080 Ti. Both of them can be shown via lspci | grep VGA.

00:02.0 VGA compatible controller: Intel Corporation Device 3e92
01:00.0 VGA compatible controller: NVIDIA Corporation GP102 [GeForce GTX 1080 Ti] (rev a1)
@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)