Skip to content

Instantly share code, notes, and snippets.

Lev E. Givon lebedov

Block or report user

Report or block lebedov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@lebedov
lebedov / google_finance_intraday.py
Last active Dec 2, 2019
Retrieve intraday stock data from Google Finance.
View google_finance_intraday.py
#!/usr/bin/env python
"""
Retrieve intraday stock data from Google Finance.
"""
import csv
import datetime
import re
import pandas as pd
@lebedov
lebedov / mpi4py_pycuda_demo.py
Last active Nov 18, 2019
Demo of how to pass GPU memory managed by pycuda to mpi4py.
View mpi4py_pycuda_demo.py
#!/usr/bin/env python
"""
Demo of how to pass GPU memory managed by pycuda to mpi4py.
Notes
-----
This code can be used to perform peer-to-peer communication of data via
NVIDIA's GPUDirect technology if mpi4py has been built against a
CUDA-enabled MPI implementation.
@lebedov
lebedov / lasso_imshow.py
Last active Oct 2, 2019
How to interactively select part of an array displayed as an image with matplotlib.
View lasso_imshow.py
#!/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
@lebedov
lebedov / lsof_funcs.py
Last active Aug 27, 2019
Python functions for finding open files and PIDs that have opened a file.
View lsof_funcs.py
#!/usr/bin/env python
"""
Python functions for finding open files and PIDs that have opened a file.
"""
import numbers
import subprocess
try:
@lebedov
lebedov / pycuda_req_rep_demo.py
Created Apr 16, 2012
Interprocess communication with pyzmq and multiprocessing
View pycuda_req_rep_demo.py
#!/usr/bin/env python
"""
Pass data between processes started through the multiprocessing module
using pyzmq and process them with PyCUDA
"""
import numpy as np
import zmq
import multiprocessing as mp
@lebedov
lebedov / jpype_api_demo.py
Last active Aug 4, 2019
How to call pdfbox's API with JPype.
View jpype_api_demo.py
#!/usr/bin/env python3
"""
How to call pdfbox's API with JPype.
"""
import jpype
import jpype.imports
import numpy as np
@lebedov
lebedov / pytorch_get_used_mem.py
Created Jun 24, 2019
Compute total memory consumed by PyTorch tensors
View pytorch_get_used_mem.py
#!/usr/bin/env python3
"""
Compute total memory consumed by PyTorch tensors.
"""
import gc
import torch
@lebedov
lebedov / queue_pool_demo.py
Created Jun 11, 2014
How to use multiple queues for passing data to/from a multiprocessing pool.
View queue_pool_demo.py
#!/usr/bin/env python
"""
How to use multiple queues for passing data to/from a multiprocessing pool.
"""
from multiprocessing import Pool, Queue
import shortuuid
def f(q_in, q_out):
@lebedov
lebedov / .bashrc
Created May 2, 2019
Bash tab completion of environment names when using conda activate
View .bashrc
#!/bin/bash
# Add the following lines to .bashrc to enable tab completion of available conda
# environment names when using conda activate. Assumes conda and jq are in one's PATH:
export CONDA_ENV_LIST=`conda env list --json | jq -r '[ .envs[1:][] | split("/")[-1] ] | join(" ")'`
complete -W "$CONDA_ENV_LIST" conda activate
@lebedov
lebedov / cuda_cpp_class.cu
Created Apr 24, 2017
How to "wrap" a CUDA kernel with a C++ class.
View cuda_cpp_class.cu
// How to "wrap" a CUDA kernel with a C++ class; the kernel must be defined outside of
// the class and launched from within a class instance's method.
#include <iostream>
#include <cuda.h>
#include <cuda_runtime.h>
#define LEN 10
__global__ void kernel(int *a, int *b, unsigned int N);
You can’t perform that action at this time.