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 / 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
(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))))
(defun arrow-right-xpm (color1 color2)
"Return an XPM right arrow string representing."
(format "/* XPM */
static char * arrow_right[] = {
\"12 18 2 1\",
\". c %s\",
\" c %s\",
\". \",
\".. \",
\"... \",
@rougier
rougier / enriched.py
Created June 20, 2020 09:21
Emacs enriched test minor mode
import json
palettes = json.load(open("material-colors.json"))
levels = [ "L50", "L100", "L200", "L300", "L400",
"L500", "L600", "L700", "L800", "L900",
"A100", "A200", "A400", "A700"]
def enriched_text(t, fg_color, bg_color, space, bold=False):
if bold: u0, u1 = "<bold>", "</bold>"
else: u0, u1 = "", ""
print(f"<x-bg-color><param>{bg_color}</param>"
@rougier
rougier / numpy-logo.svg
Created September 8, 2019 13:15
Numpy logo redesign
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rougier
rougier / emacs-animations.el
Created September 19, 2020 20:11 — forked from ivan-krukov/emacs-animations.el
Emacs-mac animations
;; animations
;; Requires =emacs-mac= fork
;; repo: https://bitbucket.org/mituharu/emacs-mac
;; homebrew tap: https://github.com/railwaycat/homebrew-emacsmacport
;; Crazy example
(mac-start-animation nil :type 'page-curl-with-shadow
:duration 1.0 :direction 'right :angle 45)
;; Less crazy
(mac-start-animation (selected-window) :type 'move-out
@rougier
rougier / rounded-box.el
Last active October 3, 2020 13:24
SVG Rounded box for Emacs
(require 'svg)
;; Rounded boxes using SVG:
;; This could be made into a function but size of text needs to be computed
(defun tag (text &optional foreground background font-size)
(let* ((font-size (or font-size 12))
;; The char-width ratio depends on the font family
(char-width (* font-size 0.58))
(char-height (+ font-size 1))
@rougier
rougier / material-colors.el
Created July 31, 2020 17:54
Emacs year calendar in a dedicated frame
;; Material colors from https://material.io/design/color/
(defconst levels
(list "L50" "L100" "L200" "L300" "L400"
"L500" "L600" "L700" "L800" "L900"
"A100" "A200" "A400" "A700"))
(defconst red
(list "#FFEBEE" "#FFCDD2" "#EF9A9A" "#E57373" "#EF5350"
"#F44336" "#E53935" "#D32F2F" "#C62828" "#B71C1C"
"#FF8A80" "#FF5252" "#FF1744" "#D50000"))
@rougier
rougier / gist:ddb84c16c28f7cd75e27e50d4c3c43da
Created August 1, 2020 17:48
Elegant Emacs daily agenda
(defun elegant-agenda (char-width char-height)
""
(interactive)
(select-frame (make-frame))
(set-frame-width (selected-frame) char-width)
(set-frame-height (selected-frame) char-height)
(set-frame-position (selected-frame)
(/ (- (display-pixel-width) (frame-outer-width)) 2)
(/ (- (display-pixel-height) (frame-outer-height)) 2))
(x-focus-frame nil)
@rougier
rougier / enhanced-message.el
Last active October 21, 2020 18:05
Emacs: persistent message in the echo area
(require 'subr-x)
(defun enhanced-message (orig-fun &rest args)
"This enhanced message displays a regular message in the echo area
and adds a specific text on the right part of the echo area. This
is to be used as an advice."
(let* ((right (propertize
;; Hack: The first space is a thin space, not a regular space
(format-time-string "  %A %d %B %Y, %H:%M ")
'face '(:height 0.85