Skip to content

Instantly share code, notes, and snippets.

View refaktor's full-sized avatar

Refaktor refaktor

View GitHub Profile
@refaktor
refaktor / main.rye
Created October 25, 2024 22:28
a little more advanced music nad hn utilities ... stil work in progress
; main.rye ... you can start this with rye -console . when in the same directory
music: context {
list: fn { "retrieves and lists soma.fm streams" } {
get https://soma.fm
|reader
|parse-html { <a> [ .attr? 'href |collect! ] } ; NOTE: collect / collected is a temp idea, don't like it that much but it solves some cases
pop-collected!
|filter { .is-match* regexp "^\/[a-z]+\.pls$" }
@refaktor
refaktor / console_241025_023710.rye
Created October 25, 2024 21:03
The saved console state after tdesk demo
; this is the result of save\current after (in) the asciinema demo:
; Building & using simple utils in Rye console https://asciinema.org/a/684031
; There are 2 bugs in current save\current that got exposed with this code and we will fix
; * -> is saved in primary form which is |_-> which caused loader error
; * [ ] blocks just recently became distinct from { }, we need to update the code to separate them too
hn: context {
hn: https://hacker-news.firebaseio.com/v0/
get-top: fn { n } { hn ._+ "topstories.json" |get |parse-json |head n |map { .to-integer } }
get-titles: fn { ids } { |map { .embed hn ._+ "item/{}.json" |get |parse-json -> "title" } }
@refaktor
refaktor / rpn_calculator.rye
Last active March 21, 2024 08:09
Improved RPN Calculator in Rye, original made by Capital-EX
; This is improved example of *RPN calculator* originally made CapitalEx from Discord/Concatenative
; https://gist.github.com/Capital-EX/d08a37765ef898cd432f662ffc7aaf98
rye .needs { fyne }
do\in fyne {
append-a: fn { n } { value-a .get-text .concat n |set-text* value-a }
num-button: fn { n } { button n [ 'append-a n ] }
calc-button: fn { lbl op1 } {
@refaktor
refaktor / hofs.rye.red
Last active February 14, 2022 16:33
HOFs test
;
; # Rye HOFs demo
;
numbers: { 1 2 3 4 }
;
; map
;
numbers |map { + 100 } |prn ; add 100 to all numbers
numbers |map { .factor-of 2 } |prn ; turn to 1 if even and 0 otherwise
numbers |map { :x , x * x } |prn ; run to it's squares
(ns clojpression-puzzle
(:require [clojure.test :refer [is]]))
(def compress (partial transduce (comp (partition-by identity)
(mapcat (fn [[c & _ :as cs]]
[(count cs) c])))
str))
(defn run [& _]
(is (= (compress "AAABBAAC") "3A2B2A1C")))