Skip to content

Instantly share code, notes, and snippets.

View dopplershift's full-sized avatar
😱
Hair on fire

Ryan May dopplershift

😱
Hair on fire
View GitHub Profile
@huyng
huyng / matplotlibrc
Created February 8, 2011 15:50
my default matplotlib settings
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@GaelVaroquaux
GaelVaroquaux / 00README.rst
Last active September 15, 2023 03:58
Copy-less bindings of C-generated arrays with Cython

Cython example of exposing C-computed arrays in Python without data copies

The goal of this example is to show how an existing C codebase for numerical computing (here c_code.c) can be wrapped in Cython to be exposed in Python.

The meat of the example is that the data is allocated in C, but exposed in Python without a copy using the PyArray_SimpleNewFromData numpy

@WeatherGod
WeatherGod / README
Created March 6, 2012 22:05
finding sensible defaults for ffmpeg (aiming for cross-compatibility)
So, provided you have some image files of form "_tmp0000.png", you can run generate_movies.sh to create a "result.txt" file which contains a list of the files successfully generated.
Additional columns are used to indicate testing status: '1' (failed), '0' (successful), '0.5' (works, but serious artifacts), '?' (couldn't try).
The script will provide the first column by testing if the movie plays using ffplay. Note, no movie gets displayed to the screen, so this is fairly quick. I have included my "result.txt" file which contains testing results for additional platforms. Platforms are:
* LibreOffice Impress on Linux
* QuickTime on Mac
* MS Office PowerPoint on Mac
* OpenOffice Impress on Mac
@deeplycloudy
deeplycloudy / audioplayer.py
Created March 21, 2012 20:37
Simple Python audio player with matplotlib and pyaudio
""" Play an audio file with pyaudio while concurrently showing audio playhead
on a matplotlib plot of the audio time series and spectrogram.
Adjust duration and filename in the script below to reflect your audio file.
v. 0.1
21 Mar 2012
Eric Bruning
"""
@vene
vene / magic_memit.py
Created June 30, 2012 06:55
memit: magic memory usage benching for IPython
# Author: Vlad Niculae <vlad@vene.ro>
# Makes use of memory_profiler from Fabian Pedregosa
# available at https://github.com/fabianp/memory_profiler
from IPython.core.magic import Magics, line_magic, magics_class
class MemMagics(Magics):
@line_magic
def memit(self, line='', setup='pass'):
import json
from pprint import pprint as pp
import numpy as np
from numba import autojit, typeof, int32
INF = float('inf')
@autojit
def jenks_matrics_init(data, n_classes, ):
@splinterofchaos
splinterofchaos / Py.h
Last active August 29, 2015 14:10
Python API in C++
#ifndef PY_H
#define PY_H
#include <Python.h>
#include <type_traits>
#include <utility>
#include <string>
template<typename R, typename...X>
@karpathy
karpathy / min-char-rnn.py
Last active June 11, 2024 01:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@teoliphant
teoliphant / rolling.py
Last active October 23, 2019 19:54
Create a function to make a "sliding_window" output array from an input array and a rolling_window size.
import numpy as np
def array_for_sliding_window(x, wshape):
"""Build a sliding-window representation of x.
The last dimension(s) of the output array contain the data of
the specific window. The number of dimensions in the output is
twice that of the input.
Parameters
@mcnees
mcnees / graph paper.tex
Last active February 16, 2024 08:34
Make your own quadrille, graph, hex, etc paper! Uses the pgf/TikZ package for LaTeX, which should be part of any modern TeX installation.
%%-----------------------------------------------------------------------
%% Make your own quadrille, graph, hex, etc paper!
%% Uses the pgf/TikZ package for LaTeX, which should be part of
%% any modern TeX installation.
%% Email: mcnees@gmail.com
%% Twitter: @mcnees
%%-----------------------------------------------------------------------
\documentclass[11pt]{article}