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
@karpathy
karpathy / min-char-rnn.py
Last active May 19, 2024 16: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)
@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).
@deeplycloudy
deeplycloudy / get_dois.sh
Created June 1, 2021 22:26
DOI URLs scraped from webpages
# Here’s the URL to a journal’s search results page for papers from the Geostationary Lightning Mapper that
# were published from 2018-2021. There are several pages of results; below is an example of the third and final URL
# Download the webpage. Do this for each page of the search results, changing the URL and output filename:
curl "https://journals.ametsoc.org/search?access_0=all&fromDate=2018&page=3&pageSize=50&q1=geostationary+lightning+mapper&sort=relevance&toDate=2021" > page3dois.txt
# Then concatenate all three files, and save out just the DOIs linked on each page.
cat page[1-3]dois.txt | grep -Eoi '<a [^>]+>' |
@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}
@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

@23ccozad
23ccozad / plot_geometry.ipynb
Last active July 1, 2023 13:52
MetPy PlotGeometry Class
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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'):
@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
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, ):