Skip to content

Instantly share code, notes, and snippets.

Avatar
🦋
Chasing butterflies

Jérôme Prudent jprudent

🦋
Chasing butterflies
View GitHub Profile
@jprudent
jprudent / Function_syntax.clj
Last active Sep 22, 2022
Functions (clojure) example
View Function_syntax.clj
;; no arguments
(fn [] (println "Hello"))
;; one argument
(fn [s] (println s))
;; two arguments
(fn [x y] (+ x y))
;; with type hint
@jprudent
jprudent / ambiant.rb
Created Mar 11, 2022
Ambiant music for sonic-pi
View ambiant.rb
use_bpm 89
def tl(name)
in_thread(name: name) do
loop do
send(name)
end
end
end
@jprudent
jprudent / random_album.js
Last active Feb 21, 2022
Play random album on deezer
View random_album.js
/*
This is semi-automated (read quick & dirty, didn't polished) way to play a random album on Deezer
You need to navigate to the fav albums page, press F12 and past this gist in the console.
*/
(async function() {
for(let i = 0; i< 500; i++) {
window.scrollTo(0, document.body.scrollHeight);
await new Promise(r => setTimeout(r, 2));
}
var playBtn = document.querySelectorAll('button.action-item-btn[aria-label=\'Pause\']');
@jprudent
jprudent / dub.rb
Created Feb 19, 2022
Sonic Pi - Dub
View dub.rb
use_bpm 128
tpb = 60 / 128.0
chord_trigg = [0, 0,1,0]
kick_trigg = [1, 0,0,0]
snare_trigg = [1, 0 ,0,0]
bass_trigg = [0,1, 0 ,1]
ks = [:kick, :snare]
define :orchestrator do
cue ks.tick(:ks) if kick_trigg.tick(:kick) > 0
View Oblique strategies
["A line has two sides", "Abandon desire", "Abandon normal instructions", "Accept advice", "Adding on", "Always the first steps", "Ask people to work against their better judgement", "Ask your body", "Be dirty", "Be extravagant", "Be less critical", "Breathe more deeply", "Bridges -build -burn", "Change ambiguities to specifics", "Change nothing and continue consistently", "Change specifics to ambiguities", "Consider transitions", "Courage!", "Cut a vital connection", "Decorate", "Destroy nothing; Destroy the most important thing", "Discard an axiom", "Disciplined self-indulgence", "Discover your formulas and abandon them", "Display your talent", "Distort time", "Do nothing for as long as possible", "Do something boring", "Do something sudden", "Do the last thing first", "Do the words need changing?", "Don't avoid what is easy", "Don't break the silence", "Don't stress one thing more than another", "Emphasize differences", "Emphasize the flaws", "Faced with a choice", "Find a safe part and use it as an anchor
@jprudent
jprudent / french.adventuron
Created Oct 14, 2021
Adventuron - Template français
View french.adventuron
######################################
# Adventuron en français #
######################################
start_at = plage
######################################
# Locations #
######################################
@jprudent
jprudent / reggaeish.rb
Created Sep 20, 2021
Some generated music with sonic-pi, reaggae like
View reggaeish.rb
use_bpm 128
tpb = 60 / 128.0
chord_trigg = [0, 0,1,0]
kick_trigg = [1, 0,0,0]
snare_trigg = [1, 0 ,0,0]
bass_trigg = [0,1, 0 ,1]
ks = [:kick, :snare]
define :orchestrator do
@jprudent
jprudent / mockito.clj
Created Sep 7, 2021
Mockito but for clojure
View mockito.clj
(defn mix-behaviours
[& behaviours]
(fn [& args]
(doseq [f (butlast behaviours)]
(apply f args))
(apply (last behaviours) args)))
(defn dyn-type
[implementations]
(let [instance (reify)
View ptrace.md

Motivations

Un debugger est un outil fabuleux : cette sensation de contrôle divin ! La possibilité de figer l'exécution d'un process et d'inspecter les arcanes de sa mémoire.

C'était les deux phrases lyriques de cet article :) Nous verrons que le divin n'est qu'une machinerie bien huilée.

Le débugger est un outil que j'utilise quotidiennement. Je trouve important d'en comprendre les mécanismes sous-jacents. Ecrire un concurrent à GDB n'est certainement pas la meilleur façon d'utiliser son temps libre. En revanche écrire un POC de débugger est certainement la manière la plus didactique d'apprendre ! Et c'est ce que je vous propose aujourd'hui, d'écrire un petit debugger pas super pratique mais fonctionnel.

Concernant le fond, cet article ne traite que de Linux sous architecture x86_64. Il part du principe que vous avez de vagues notions sur ce qu'est :

View loop3.rb
bass = (ring :d, :r, :r, :a, :f5, :r, :a, :r)
bass2 = (ring :d, :r, :r, :Bb, :g5, :r, :Bb, :r)
live_loop :hanabera do
sync :metronom
use_synth :fm
if (one_in(12))
melody = bass2
else
melody = bass
end