Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Nicolas P. Rougier rougier

:octocat:
View GitHub Profile
@rougier
rougier / clean.el
Created May 10, 2020
A very minimal but elegant emacs configuration file
View clean.el
(require 'org)
(setq-default indent-tabs-mode nil)
(setq org-display-inline-images t)
(setq org-redisplay-inline-images t)
(setq org-startup-with-inline-images "inlineimages")
(setq default-frame-alist
(append (list '(width . 72) '(height . 40))))
@rougier
rougier / fractal-dimension.py
Last active Aug 28, 2021
Fractal dimension computing
View fractal-dimension.py
# -----------------------------------------------------------------------------
# From https://en.wikipedia.org/wiki/Minkowski–Bouligand_dimension:
#
# In fractal geometry, the Minkowski–Bouligand dimension, also known as
# Minkowski dimension or box-counting dimension, is a way of determining the
# fractal dimension of a set S in a Euclidean space Rn, or more generally in a
# metric space (X, d).
# -----------------------------------------------------------------------------
import scipy.misc
import numpy as np
@rougier
rougier / Toolbar.el
Created Nov 30, 2020
Emacs SVG Toolbar
View Toolbar.el
;; An experiment for an SVG toolbar using icons from material.io
;;
;; Example usage: (toolbar 48 "black" "white" t t)
;; Material icons freely available (Apache 2 license) from
;; - https://material.io/resources/icons/?style=outline
;; - https://github.com/google/material-design-icons
(require 'xml) (require 'svg)
(defun toobar-item (label icon fg-color bg-color size with-icon with-label)
@rougier
rougier / style.css
Created Jun 23, 2021
Jupyter stylesheet
View style.css
@import url('https://fonts.googleapis.com/css2?family=Roboto+Condensed:wght@300;400&family=Source+Code+Pro:wght@300;400&display=swap');
.rendered_html h1,
.rendered_html h2,
.rendered_html h3,
.rendered_html h4 {
color: #000099;
font-weight: 400;
}
@rougier
rougier / multiline-header.el
Created Jun 3, 2020
Emacs Multiline mode-line
View multiline-header.el
;; -------------------------------------------------------------------
;; A proof of concept for a multi header or mode line
;;
;; Multi line header or mode line is made possible by generating an
;; SVG image made of two small lines of text. It is certainly memory
;; hungry but it seems to be fast enough to display line/column while
;; typing text. It can probably be extended in a number of ways.
;;
;; Feel free to modify it for your own needs.
;; -------------------------------------------------------------------
@rougier
rougier / progress_bar.py
Created Jan 25, 2016
A progress bar using unicode character for smoother display
View progress_bar.py
# -----------------------------------------------------------------------------
# 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
View mu4e-side-dashboard.el
(require 'mu4e)
(require 'mu4e-dashboard)
(setq mu4e-sidebar-frame nil)
(setq mu4e-sidebar-dashboard-file "~/.emacs.d/lisp/dashboard.org")
(defun mu4e-sidebar-create (dashboard-file)
(let ((width (frame-pixel-width))
(height (frame-pixel-height))
(frame (make-frame `((parent-frame . ,(window-frame))
View poisson-disk-sampling.py
def poisson_disk_sample(width=1.0, height=1.0, radius=0.025, k=30):
# References: Fast Poisson Disk Sampling in Arbitrary Dimensions
# Robert Bridson, SIGGRAPH, 2007
def squared_distance(p0, p1):
return (p0[0]-p1[0])**2 + (p0[1]-p1[1])**2
def random_point_around(p, k=1):
# WARNING: This is not uniform around p but we can live with it
R = np.random.uniform(radius, 2*radius, k)
T = np.random.uniform(0, 2*np.pi, k)
@rougier
rougier / binomial.py
Created Jan 25, 2016
A fast way to calculate binomial coefficients in python (Andrew Dalke)
View binomial.py
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
@rougier
rougier / agenda.py
Last active Mar 17, 2021
org-mode agenda calendar in the terminal
View agenda.py
#!/usr/bin/env python3
# Copyright 2020 Nicolas P. Rougier - BSD License
#
# from reading org-mode emacs files, display a formated calendar in the
# terminal showing holidays and busy days and upcomiing events.
import holidays # https://pypi.org/project/holidays/
import calendar
import datetime
import orgparse # https://pypi.org/project/orgparse