Skip to content

Instantly share code, notes, and snippets.

Avatar

Sébastien Pierre sebastien

View GitHub Profile
View spherical.py
# encoding: utf-8
from math import cos, sin, acos, asin, atan2, sqrt, pi
"""
A simple sketch to make sure spherical projection and unprojections work
properly. There are many ways to encode them, so this one assumes
THETA as rotating around Y (horizontal plane positionning) and PHI as the
rotation around Z (vertical positioning), so that THETA can be considered
the spherical X and PHI the spherical Y.
View study-waves-01.curv
let
EPSILON = 0.001;
between (v,a,b) = 1 - smoothstep(a-EPSILON,a+EPSILON,v) + smoothstep(b-EPSILON,b+EPSILON,v);
prel (v,a,b) = (v - a)/(b - a);
scale (v,a,b) = lerp(b[0],b[1],prel(v,a[0],a[1]));
hash x = frac(sin(x)*100000.0);
wave (x,y,z,t) = let
View study-organic-03.curv
let
hash2x2 xy = frac([262144, 32768] * sin(dot(xy, [41, 289])));
// TODO: Rephrase in a more functional style, compose passes for clarity.
// TODO: The voronoi input should be a vec3
// TODO: There seems to be some odd artifacts
//matrix (n,m) = [for (i in 0..<floor(n*m)) [mod(i,n),floor(i/n)] ];
between(v,a,b) = if (a <= v && v <= b) 0.0 else 1.0;
View study-randompoints.curv
// A study of rendering varyingly shaped points with randomized positions
// with a discrete gradient o density.
//
// Ref: https://www.tylerlhobbs.com/works/item/st-c
//
// It is an opportunity to study randomness (or pseudo-randomness) in curv,
// as well as how to define varying densities of points.
let
View study-sinetriangles.curv
// Triangle study
// Ref: https://otakugangsta.com/image/180451216975
let
w = 28;
h = 34;
black = (0.016, 0.031, 0.027);
// NOTE: Here we need to add an EPSILON otherwise the polygon
// drawing will fail.
@sebastien
sebastien / show-ansi-colors.sh
Created Oct 25, 2018 — forked from eliranmal/show-ansi-colors.sh
spits N ansi colors to the terminal
View show-ansi-colors.sh
#!/usr/bin/env sh
usage() {
echo "show-ansi-colors <n>"
exit 0
}
(( $# < 1 )) && usage
show_ansi_colors() {
@sebastien
sebastien / acpi_yogaX1_fedora28
Created Sep 5, 2018 — forked from javanna/acpi_yogaX1_fedora28
S3 deep sleep for Lenovo yoga X1 3rd Generation on Fedora 28
View acpi_yogaX1_fedora28
This is a step-by-step guide on how make sleep mode work with a Lenovo Yoga X1 3rd generation running Fedora 28 (UEFI based system).
Kernel version: 4.17.4-200.fc28.x86_64
Credits: most of this guide comes from `https://delta-xi.net/#056`. The patch I used is a little different though, taken from http://kernel.dk/acpi.patch
(found through https://bbs.archlinux.org/viewtopic.php?pid=1794150#p1794150), and some of the steps slightly differ as well as mine is a UEFI based system.
1. Reboot, enter BIOS/UEFI. Go to Config - Thunderbolt (TM) 3 - set Thunderbolt BIOS Assist Mode to Enabled. Set also Security - Secure Boot to Disabled.
2. Install iasl (Intel's compiler/decompiler for ACPI machine language) and cpio: `sudo yum install acpica-tools cpio`
View init.vim
" Test completion on NeoVim. Completion should automatically pop-up on
" insertion.
silent! packadd minpac
if !exists('*minpac#init')
!mkdir $(dirname $MYVIMRC)/pack/minpac/opt ; true
!git clone https://github.com/k-takata/minpac.git $(dirname $MYVIMRC)/pack/minpac/opt/minpac
silent! packadd minpac
endif
call minpac#init()
call minpac#add('k-takata/minpac', {'type': 'opt'})
@sebastien
sebastien / nix-fishgen.py
Last active May 17, 2020
Python script that converts Nix's profile bash script to Fish
View nix-fishgen.py
#!/usr/bin/env python3
# Updated: 2018-10-17
import re, sys, os
"""
Converts the Nix profile SH script to a Fish-compatible profile using a
simple line-by-line replace algorithm.
"""
@sebastien
sebastien / fish_hg_prompt.fish
Created Dec 6, 2017
Mercurial prompt tools for Fish shell
View fish_hg_prompt.fish
function fish_hg_prompt --description 'Prompt function for Mercurial'
# BRANCH ⑂3 ‥+-?! [RNNN|D]
# 1 2 3 4 5
#
# 1 = Current branch/bookmark
# 2 = Number of heads/branches
# 3 = Modified ‥ added + removed - untracked ? merge !
# 4 = Revision number
# 5 = Time since last commit
You can’t perform that action at this time.