Skip to content

Instantly share code, notes, and snippets.

View rougier's full-sized avatar
:octocat:

Nicolas P. Rougier rougier

:octocat:
View GitHub Profile
@gitaarik
gitaarik / git_submodules.md
Last active May 17, 2025 14:51
Git Submodules basic explanation

Git Submodules basic explanation

Why submodules?

In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:

  • Separate big codebases into multiple repositories.
@nocturnalgeek
nocturnalgeek / MailinatorAliases
Last active August 21, 2024 01:58
A list of alternate domains that point to @mailinator.com
@binkmail.com
@bobmail.info
@chammy.info
@devnullmail.com
@letthemeatspam.com
@mailinater.com
@mailinator.net
@mailinator2.com
@notmailinator.com
@reallymymail.com
@alimuldal
alimuldal / dunn.py
Last active October 5, 2023 06:04
Implementation of Dunn's multiple comparison test, following a Kruskal-Wallis 1-way ANOVA
import numpy as np
from scipy import stats
from itertools import combinations
from statsmodels.stats.multitest import multipletests
from statsmodels.stats.libqsturng import psturng
import warnings
def kw_dunn(groups, to_compare=None, alpha=0.05, method='bonf'):
"""
@glen-cheney
glen-cheney / encoding-video.md
Last active November 24, 2024 10:09
Encoding video for the web

Encoding Video

Installing

Install FFmpeg with homebrew. You'll need to install it with a couple flags for webm and the AAC audio codec.

brew install ffmpeg --with-libvpx --with-libvorbis --with-fdk-aac --with-opus
@rougier
rougier / prefix.py
Created January 10, 2016 20:47
SI and IEC prefix for printing human readable numbers
# Copyright (c) 2016 Nicolas P. Rougier - BSD License
# SI prefixes as name:value
SI_prefix_name_value = {
"yocto": 10e-24, "zepto": 10e-21, "atto": 10e-18, "femto": 10e-15,
"pico": 10e-12, "nano": 10e-9, "micro": 10e-6, "milli": 10e-3,
"centi": 10e-2, "deci": 10e-1, "deca": 10e1, "hecto": 10e2,
"kilo": 10e3, "mega": 10e6, "giga": 10e9, "tera": 10e12,
"peta": 10e15, "exa": 10e18, "zetta": 10e21, "yotta": 10e24 }
@rougier
rougier / glut-cube.py
Created January 20, 2016 07:06
Rotating color cube using modern GL, glut and python
# -----------------------------------------------------------------------------
# Copyright (c) 2016 Nicolas P. Rougier. All rights reserved.
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
import sys
import math
import ctypes
import numpy as np
import OpenGL.GL as gl
import OpenGL.GLUT as glut
@rougier
rougier / progress_bar.py
Created January 25, 2016 06:25
A progress bar using unicode character for smoother display
# -----------------------------------------------------------------------------
# Copyright (c) 2016, Nicolas P. Rougier
# Distributed under the (new) BSD License.
# -----------------------------------------------------------------------------
import sys, math
def progress(value, length=40, title = " ", vmin=0.0, vmax=1.0):
"""
Text progress bar
@rougier
rougier / binomial.py
Created January 25, 2016 09:50
A fast way to calculate binomial coefficients in python (Andrew Dalke)
def binomial(n, k):
"""
A fast way to calculate binomial coefficients by Andrew Dalke.
See http://stackoverflow.com/questions/3025162/statistics-combinations-in-python
"""
if 0 <= k <= n:
ntok = 1
ktok = 1
for t in xrange(1, min(k, n - k) + 1):
ntok *= n
@dannguyen
dannguyen / matplotlib-basemap-python3x-quakes.md
Last active January 24, 2023 07:22
How to use matplotlib's basemap and Python 3.x to plot earthquake data on a world map

Mapping earthquakes in Python 3.x using matplotlib and matplotlib's basemap

(with a big assist from Anaconda)

I currently use Python for nearly all of my data science and wrangling work these days but usually find myself switching to R to visualize data using ggplot2. This is due in part to ggplot2's general excellence, but also because I had a lot of trouble learning Python's most popular viz library, matplotlib on my own...its homepage is decent enough...but its variety of plotting APIs (--pylab? OOP? %matplotlib???) has led to widely differing examples and best practices among the many online matplotlib guides (not dissimilar to the general problem of trying to practice either Python 2.x or 3.x).

That changed yesterday when I stumbled across [Nicolas P. Rougier's beautifully designed and com

@mdboom
mdboom / datashader-matplotlib-mashup.py
Last active April 23, 2020 10:59
The absolute bare minimum to get datashader working in matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import datashader as ds
import datashader.transfer_functions as tf
from datashader.colors import Hot
time_period = 60