Skip to content

Instantly share code, notes, and snippets.

View rougier's full-sized avatar
:octocat:

Nicolas P. Rougier rougier

:octocat:
View GitHub Profile
@rougier
rougier / bordered-emacs.el
Last active January 16, 2021 22:58
Bordered emacs
;; Copyright 2020 Nicolas Rougier - BSD License
;; Usage: emacs -q -l bordered.el
(set-face-font 'default "Roboto Mono Light 14")
(setq default-frame-alist
(append (list '(width . 72) '(height . 40)
'(vertical-scroll-bars . nil)
'(internal-border-width . 0)
'(font . "Roboto Mono Light 14"))))
(set-frame-parameter (selected-frame)
'internal-border-width 0)
@rougier
rougier / poisson-disk-sampling.py
Created November 15, 2016 16:42
Poisson disk sampling
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 / mu4e-mockup.el
Created September 26, 2021 09:37
Emacs / Mu4e configuration for threaded view (with folding)
;; mu4e setup -*- lexical-binding: t; -*-
;; This file is not part of GNU Emacs.
;;
;; This program is free software: you can redistribute it and/or
;; modify it under the terms of the GNU General Public License as
;; published by the Free Software Foundation, either version 3 of the
;; License, or (at your option) any later version.
;;
;; This program is distributed in the hope that it will be useful, but
@rougier
rougier / init-agenda.el
Created November 28, 2021 17:38
Org agenda with dynamics icons
(require 'svg-lib)
(defun org-agenda-custom-date ()
(interactive)
(let* ((timestamp (org-entry-get nil "TIMESTAMP"))
(timestamp (or timestamp (org-entry-get nil "DEADLINE"))))
(if timestamp
(let* ((timestamp (ts-parse-org timestamp))
(delta (/ (ts-diff timestamp (ts-now)) (* 24 60 60)))
(delta (/ (+ 1 delta) 30))
@rougier
rougier / drop-shadows.el
Last active December 2, 2021 06:23
Emacs drop shadows
(require 'xml)
(require 'svg)
(let* ((text "Hello world!")
(font (query-font (font-at (point-min))))
(font-size (elt font 2))
(family (face-attribute 'default :family))
(descent (elt font 4))
(ascent (elt font 5))
(svg-height (+ ascent descent))
@rougier
rougier / bibliography.org
Created December 29, 2021 14:29
Literate & annotated bibliography using NANO Emacs & orgmode

Unsorted

To Read

Neuroscience needs evolution [cite:@Cisek:2021] |PDF|

@article{Cisek:2021,
  title =        {Neuroscience needs evolution},
# From https://stackoverflow.com/questions/9755538/how-do-i-create-a-list-of-random-numbers-without-duplicates
# Code by Thomas Lux
#
# Return a randomized "range" using a Linear Congruential Generator
# to produce the number sequence. Parameters are the same as for
# python builtin "range".
# Memory -- storage for 8 integers, regardless of parameters.
# Compute -- at most 2*"maximum" steps required to generate sequence.
#
def random_range(start, stop=None, step=None):
@rougier
rougier / emacs-dnd-protocol.el
Created April 30, 2022 12:57
GNU Emacs DND protocol
;; Open scratch buffer, evalute code below and drag and drop some files onto the scratch buffer.
;; Code by Ivan Tadeu Ferreira Antunes Filho
;; https://ivanaf.com/emacs_drag-drop_pdfs_paste_html_custom_templates.html
(defun scratch--file-insert (uri)
(message "%s" uri))
(defun scratch--file-dnd-fallback (uri action)
(let ((dnd-protocol-alist
(rassq-delete-all 'scratch--file-dnd-protocol
@rougier
rougier / imenu-filter.org
Created May 7, 2022 18:06
Filter for imenu-list

Section 1

Section 1.1

Section 1.1.1

Section 1.1.2

Section 1.2

Section 1.2.1

Section 1.2.2

@rougier
rougier / bibtex.png
Created July 18, 2022 04:22 — forked from max-mapper/bibtex.png
How to make a scientific looking PDF from markdown (with bibliography)
bibtex.png