Skip to content

Instantly share code, notes, and snippets.

View nvictus's full-sized avatar

Nezar Abdennur nvictus

  • UMass Chan Medical School
  • Greater Boston Area
View GitHub Profile
@mobilemind
mobilemind / git-tag-delete-local-and-remote.sh
Last active April 15, 2024 00:30
how to delete a git tag locally and remote
# delete local tag '12345'
git tag -d 12345
# delete remote tag '12345' (eg, GitHub version too)
git push origin :refs/tags/12345
# alternative approach
git push --delete origin tagName
git tag -d tagName
@clemsos
clemsos / csv_to_elastic_search_bulk_insert.py
Last active February 27, 2024 10:15
Elastic Search : index large csv files with Python Pandas
from pyelasticsearch import ElasticSearch
import pandas as pd
from time import time
root_path="/home/clemsos/Dev/mitras/"
raw_data_path=root_path+"data/"
csv_filename="week10.csv"
t0=time()
@ajelenak
ajelenak / h5-to-zarr.py
Last active March 1, 2023 16:04
Python code to extract HDF5 chunk locations and add them to Zarr metadata.
# Requirements:
# HDF5 library version 1.10.5 or later
# h5py version 3.0 or later
# pip install git+https://github.com/HDFGroup/zarr-python.git@hdf5
import logging
from urllib.parse import urlparse, urlunparse
import numpy as np
import h5py
import zarr
@lebedov
lebedov / lasso_imshow.py
Last active May 2, 2022 08:12
How to interactively select part of an array displayed as an image with matplotlib.
#!/usr/bin/env python
"""
How to interactively select part of an array displayed as an image with matplotlib.
"""
import matplotlib.pyplot as plt
from matplotlib.path import Path
from matplotlib.widgets import LassoSelector
import numpy as np
@eric-hu
eric-hu / Open iterm tab here
Last active March 11, 2022 02:45
Apple script to open an iterm2 tab from right-clicking on a file or folder in Finder. To use: (1) Open Automator (2) Create a new service (3) Change "Service receives selected" drop downs to "Files or folders" in "Finder" (4) Select "Run applescript" from the sidebar, then paste this script in and save
-- Adapted from these sources:
-- http://peterdowns.com/posts/open-iterm-finder-service.html
-- https://gist.github.com/cowboy/905546
--
-- Modified to work with files as well, cd-ing to their container folder
on run {input, parameters}
tell application "Finder"
set my_file to first item of input
set filetype to (kind of (info for my_file))
-- Treats OS X applications as files. To treat them as folders, integrate this SO answer:
@acrosby
acrosby / rtree_large_test.py
Last active December 9, 2020 15:50
Sample code for python rtree bulk loading of 10,000,000 points and a nearest neighbor query.
from rtree import index
from random import random
from datetime import datetime
timer = datetime.now()
# Create 10,000,000 random numbers between 0 and 1
rands = [random() for i in range(10000000)]
# Function required to bulk load the random points into the index