Skip to content

Instantly share code, notes, and snippets.

View lebedov's full-sized avatar

Lev E. Givon lebedov

View GitHub Profile
@lebedov
lebedov / ipc_demo.py
Created March 17, 2013 01:48
Demonstrate how to pass IPC handles to GPU data between processes in Python
#!/usr/bin/env python
"""
Demonstrate how to pass IPC handles to GPU data between processes in Python.
"""
import ctypes
import numpy as np
import multiprocessing as mp
import zmq
@lebedov
lebedov / msgpack_pandas_attrib.py
Created July 23, 2014 16:48
Serialize/unserialize a class with a pandas data structure attribute using msgpack.
#!/usr/bin/env python
"""
Serialize/unserialize a class with a pandas data structure attribute using msgpack.
"""
import msgpack
import numpy as np
import pandas as pd
@lebedov
lebedov / google_finance_intraday.py
Last active February 20, 2024 09:44
Retrieve intraday stock data from Google Finance.
#!/usr/bin/env python
"""
Retrieve intraday stock data from Google Finance.
"""
import csv
import datetime
import re
import pandas as pd
@lebedov
lebedov / lsof_funcs.py
Last active January 24, 2024 02:09
Python functions for finding open files and PIDs that have opened a file.
#!/usr/bin/env python
"""
Python functions for finding open files and PIDs that have opened a file.
"""
import numbers
import subprocess
try:
@lebedov
lebedov / headless.sh
Created August 13, 2012 19:50
Using Xvfb to create a headless display
#!/bin/bash
# Demonstrates how to create a headless display using xvfb.
# Create the display:
Xvfb :100 -ac &
PID1=$!
export DISPLAY=:100.0
# Run the application that needs the display:
@lebedov
lebedov / ct_win.py
Created April 6, 2017 16:49
Routines for scaling biomedical image data by window level and width.
#!/usr/bin/env python
"""
Routines for scaling biomedical image data by window level and width.
"""
import numpy as np
win_dict = {'abdomen':
{'wl': 60, 'ww': 400},
@lebedov
lebedov / cuda_cpp_class.cu
Created April 24, 2017 21:56
How to "wrap" a CUDA kernel with a C++ class.
// 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);
@lebedov
lebedov / jpype_pdf_text_stripper.py
Created April 28, 2021 12:29
How to use pdfbox's PDFTextStripper class in Python.
#!/usr/bin/env python3
"""
How to use pdfbox's PDFTextStripper class in Python.
"""
import pathlib
import pkg_resources
import re
import urllib.request
@lebedov
lebedov / jpype_api_demo.py
Last active July 10, 2023 14:04
How to call pdfbox's API with JPype.
#!/usr/bin/env python3
"""
How to call pdfbox's API with JPype.
"""
import pathlib
import pkg_resources
import re
import urllib.request
@lebedov
lebedov / mp_pool_zmq_demo.py
Last active May 24, 2023 01:40
Farm out processing to multiple processes via zmq.
#!/usr/bin/env python
"""
Farm out processing to multiple processes via zmq.
"""
import re, pickle, time, threading
import multiprocessing as mp
import zmq
from zmq.eventloop.ioloop import IOLoop