This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| funcs: | |
| python setup.py build_ext --inplace | |
| test: funcs | |
| gcc -L. test.c -o test -lmyfuncs | |
| clean: | |
| rm -f test *.o *.so funcs.c |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cProfile | |
| import functools | |
| def do_cprofile(*dec_args): | |
| """ | |
| Decorator for profiling functions. | |
| If a file name is passed to the decorator as an argument, profiling data | |
| will be written to that file; otherwise, it will be displayed on the screen. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| How to synchronize ZeroMQ routers and dealers. | |
| """ | |
| import multiprocessing as mp | |
| import zmq | |
| IPC_PATH = 'ipc://zmq_router_dealer_sync' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Get LinkedIn OAuth1 access tokens without having to open a web browser. | |
| Notes | |
| ----- | |
| Based upon https://developer.linkedin.com/documents/getting-oauth-token-python | |
| Assumes that the application API key, secret key, user name, and password are stored |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Automatically create and submit Torque job script with specified commands to qsub. | |
| """ | |
| import argparse | |
| import os | |
| import pwd | |
| import tempfile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python2.7 | |
| """ | |
| torque submit filter that automatically sets CUDA_VISIBLE_DEVICES | |
| based upon the number of GPUs requested in a job. | |
| Notes | |
| ----- | |
| Assumes that /var/spool/torque/filters/trqgpu.py is available. | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Add these functions to your ~/.bashrc file. | |
| function mktunnel { | |
| if [[ $* == '' ]] || [[ $1 == '-h' ]]; then | |
| echo 'Usage: mktunnel LOCALPORT REMOTEPORT REMOTEHOST' | |
| else | |
| ssh -fCNL $1:localhost:$2 $3; | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """ | |
| Consecutively renumber prompts in an IPython notebook. | |
| """ | |
| # Copyright (c) 2015, Lev Givon | |
| # All rights reserved. | |
| # Distributed under the terms of the BSD license: | |
| # http://www.opensource.org/licenses/bsd-license |