Skip to content

Instantly share code, notes, and snippets.

View lebedov's full-sized avatar

Lev E. Givon lebedov

View GitHub Profile
@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 / change_imshow_ticks.py
Created October 24, 2012 03:35
How to replace tick labels for an image displayed with matplotlib
#!/usr/bin/env python
"""
Demonstrate how to replace tick labels for a displayed image.
"""
import numpy as np
import pylab as pl
im = np.random.rand(100, 200)
@lebedov
lebedov / test_pinned_register.py
Created November 8, 2012 02:47
Compare performance of using host-registered pinned and unpinned host memory
#!/usr/bin/env python
"""
Compare performance of using host-registered pinned and unpinned host memory.
"""
import numpy as np
import pycuda.autoinit
import pycuda.driver as drv
@lebedov
lebedov / test_pinned_prealloc.py
Created November 8, 2012 02:48
Compare performance of using preallocated pinned and unpinned host memory
#!/usr/bin/env python
"""
Compare performance of using pinned and unpinned host memory.
"""
import numpy as np
import pycuda.autoinit
import pycuda.driver as drv
@lebedov
lebedov / mexfunc.cpp
Created November 29, 2012 20:07
Simple example of a MEX function
// Simple example of a MEX function. Save this as mexfunc.cpp and compile with
// mex; it can then be called as mexfunc(something) from MATLAB.
#include <math.h>
#include <matrix.h>
#include <mex.h>
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
mxArray *a_in, *b_out;
const mwSize *dims;
@lebedov
lebedov / find_rank.py
Created December 17, 2012 22:54
Demo of how to find the order of several entries in a row of numerical data.
#!/usr/bin/env python
"""
Demo of how to find the order of several entries in a row of numerical data.
"""
import numpy as np
import pandas
df = pandas.DataFrame(np.random.rand(5, 3), columns=['a', 'b', 'c'])
@lebedov
lebedov / freq_shift_ssb.py
Last active April 10, 2023 20:37
Frequency shift a signal using SSB modulation.
#!/usr/bin/env python
"""
Frequency shift a signal using SSB modulation.
"""
import numpy as np
import scipy as sp
import scipy.signal
import matplotlib.pyplot as plt
@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
@lebedov
lebedov / mpl_zmq_animate.py
Created March 7, 2013 00:06
Plot data received over a ZeroMQ port in real time using matplotlib.
#!/usr/bin/env python
"""
Plot data received over a ZeroMQ port in real time using matplotlib.
Notes
-----
This appears to segfault when run using the WxAgg backend.
"""
@lebedov
lebedov / get_elf_soname.py
Last active December 14, 2015 15:59
Extract SONAME of a shared library.
#!/usr/bin/env python
"""
Extract SONAME of a shared library.
"""
import sys
if len(sys.argv) < 2:
print 'usage: get_elf_soname.py <library path>'