Skip to content

Instantly share code, notes, and snippets.

@pmav99
pmav99 / append_to_parquet.ipynb
Last active September 8, 2023 08:18
append to parquet files
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pmav99
pmav99 / split_quads.md
Last active August 2, 2022 07:42
Split quads using numpy

image

image

import numpy as np

face_nodes = np.array([
    [1, 2, 6, np.nan],
    [1, 6, 5, np.nan],
@pmav99
pmav99 / dotted_to_nested.py
Created November 28, 2021 12:29
Convert a "dotted" dictionary to a nested one
from functools import reduce
from typing import Any
from typing import Dict
def merge(a, b, path=None):
""" Merge dictionary a into b (in-place)"""
# source: https://stackoverflow.com/a/7205107/592289
if path is None: path = []
for key in b:
@pmav99
pmav99 / transform_epsg_4326_to_3857_with_pyproj.py
Created December 18, 2020 23:10
Convert epsg:4326 to epsg:3857 using the latest version of pyproj
import numpy as np
import pyproj
# Use the "new" numpy API for the random number generation (requires numpy >=1.17)
rng = np.random.default_rng(seed=1)
# Create arrays with random points
no_points = 5
longitudes = rng.uniform(low=10, high=20, size=no_points)
latitudes = rng.uniform(low=33, high=45, size=no_points)
@pmav99
pmav99 / gatttool-polar-h10.txt
Created November 24, 2020 20:32 — forked from fphammerle/gatttool-polar-h10.txt
bluez gatttool: receive heart rate notifications from polar h10 (bluetooth heart rate sensor)
$ sudo hcitool lescan
AA:BB:CC:DD:EE:FF Polar H10 ABCDEFGH
$ gatttool -t random --device=AA:BB:CC:DD:EE:FF --interactive
[AA:BB:CC:DD:EE:FF][LE]> connect
Attempting to connect to AA:BB:CC:DD:EE:FF
Connection successful
[AA:BB:CC:DD:EE:FF][LE]> primary
attr handle: 0x0001, end grp handle: 0x0009 uuid: 00001800-0000-1000-8000-00805f9b34fb
attr handle: 0x000a, end grp handle: 0x000d uuid: 00001801-0000-1000-8000-00805f9b34fb
@pmav99
pmav99 / test_tf.py
Last active October 22, 2019 13:33
Simple tensorflow test
#!/usr/bin/env python3
import datetime
import numpy as np
import tensorflow as tf
# Processing Units logs
log_device_placement = True
@pmav99
pmav99 / verify_password.py
Created October 21, 2019 09:36
Verify jupyter / ipython password hashlib
import hashlib
import sys
if len(sys.argv) != 3:
sys.exit("Usage: python3 verify.py hash passphrase")
provided_hash = sys.argv[1]
passphrase = sys.argv[2]
salt = provided_hash.split(":")[1]
@pmav99
pmav99 / test_single_gpu.py
Created August 8, 2019 13:28 — forked from j-min/test_single_gpu.py
TensorFlow single GPU example
from __future__ import print_function
'''
Basic Multi GPU computation example using TensorFlow library.
Author: Aymeric Damien
Project: https://github.com/aymericdamien/TensorFlow-Examples/
'''
'''
This tutorial requires your machine to have 1 GPU
"/cpu:0": The CPU of your machine.
@pmav99
pmav99 / qgis_processing_api_example.py
Last active June 19, 2019 10:49
QGIS 3 + Processing + Python API example
import os
import pathlib
import sys
import typing
# The exact values of these paths depend on your QGIS installation
QGIS_ROOT = pathlib.Path("/opt/qgis-git")
QGIS_PATH = QGIS_ROOT / "share/qgis/python"
QGIS_PLUGIN_PATH = QGIS_PATH / "plugins"