Skip to content

Instantly share code, notes, and snippets.

View ruliana's full-sized avatar

Ronie Uliana ruliana

View GitHub Profile
(defvar ronie/god-tab-mode-map (make-sparse-keymap))
(define-minor-mode ronie/god-tab-mode
"Make <tab> a 'god key' for editing code, according to the context and my preferences ;p"
:lighter " GT"
:keymap ronie/god-tab-mode-map
(if (bound-and-true-p ronie/god-tab-mode)
(message "Jumper mode activated!")
(message "Jumper mode deactivated!")))
@ruliana
ruliana / print_keyboard_layout.sh
Created September 15, 2019 20:46
Print the keyboard layout in pdf
xkbprint -label name -o keyboard-layout.ps $DISPLAY; ps2pdf keyboard-layout.ps
@ruliana
ruliana / maze01.scm
Created September 11, 2019 02:43
Mazes for Programmers in Guile Scheme. Binary Tree and Sidewinder algorithms implemented.
(use-modules (oop goops)
(srfi srfi-1) ;; sane lists
(srfi srfi-26) ;; cut
(srfi srfi-42) ;; list comprehension
(srfi srfi-69) ;; hash-table
(srfi srfi-88)) ;; keywords
;; Upper lambda as an alias for "cut"
(define-syntax Λ (identifier-syntax cut))
@ruliana
ruliana / sane-extensions.scm
Last active June 14, 2023 07:42
Sprinkling some syntax sugar on Guile Scheme to make it more pratical. Let's say "better defaults" for my personal taste :)
(use-modules (srfi srfi-1) ;; list operations
(srfi srfi-11) ;; let-values
(srfi srfi-41) ;; streams
(srfi srfi-42) ;; list comprehension
(srfi srfi-88) ;; keyword as "this:", not only "#:this"
(oop goops) ;; function overloading ("OOP" is _not_ the main point)
((ice-9 format) #:prefix fmt.))
(define-syntax def (identifier-syntax define-method))
@ruliana
ruliana / .xmodmap
Created September 7, 2019 17:09
My xmodmap with brazilian portuguese mapping and mathematical symbols (with more common greek letters)
keycode 8 =
keycode 9 = Caps_Lock NoSymbol Caps_Lock
keycode 10 = 1 exclam 1 exclam onesuperior exclamdown
keycode 11 = 2 at 2 at twosuperior onehalf
keycode 12 = 3 numbersign 3 numbersign threesuperior threequarters
keycode 13 = 4 dollar 4 dollar sterling onequarter
keycode 14 = 5 percent 5 percent cent U2030
keycode 15 = 6 dead_diaeresis 6 asciicircum notsign diaeresis
keycode 16 = 7 ampersand 7 ampersand dead_belowdot dead_abovedot
keycode 17 = 8 asterisk 8 asterisk dead_ogonek dead_horn
@ruliana
ruliana / pre-conditions.ss
Created August 28, 2019 20:40
Function selection based on pre-conditions in Chez Scheme (very nice exercise using call/cc)
(define (pre-condition assertion) 'noop)
(define (try . procs)
(let loop ([procs procs])
(define proc (car procs))
(define (make-pre-condition k)
(lambda (assertion)
(when (not assertion)
(k (lambda () (loop (cdr procs)))))))
(define (exec k)
@ruliana
ruliana / wip.ss
Created August 9, 2019 23:04
Fighting scheme macros
(define empty? null?)
(define empty '())
(define first car)
(define rest cdr)
(define (split2 item lst)
(let loop ([remaining lst]
[left empty])
(cond [(empty? remaining) (values (reverse left) empty)]
[(equal? item (first remaining)) (values (reverse left) (rest remaining))]
@ruliana
ruliana / power-let.ss
Created August 6, 2019 21:07
Scheme "power-let" exploring
(trace-define-syntax power-let
(syntax-rules (<-)
[(_ (v <- expr) rest ...) (let [(v expr)] (power-let rest ...))]
[(_ body0 body* ...) (begin body0 body* ...)]))
(define-syntax def
(syntax-rules ()
((_ (name args ...) body ...)
(define (name args ...)
(power-let body ...)))))
@ruliana
ruliana / word_game.js
Last active August 2, 2019 02:33
Making the "Preposition Game" a little better (still not there)
function wordGame(words) {
let clicks = 0;
let correct = 0;
function updateScore() {
let score = document.querySelectorAll('.word-game-score-panel')[0];
if (clicks == 0) {
score.innerHTML = "The Preposition Game<br>Accuracy: 0%";
} else {
let accuracy = Math.round(correct / clicks * 100);
@ruliana
ruliana / preposition_game.js
Created August 1, 2019 03:05
Let's guess what's the correct preposition (on, at, in). Create as bookmarket with it :)
function printSolution(element) {
let answer = element.getAttribute("data-answer");
let selectedOptions = Array.from(element.selectedOptions).map(e => e.text);
if (selectedOptions.includes(answer)) {
element.style.border = "2px solid green";
} else {
element.style.border = "2px solid red";
}
}
let prepositions = ["", "on", "at", "in"];