Skip to content

Instantly share code, notes, and snippets.

@Idorobots
Idorobots / loop.lisp
Created July 20, 2012 16:31
Common Lisp LOOP example and output
(let ((random (loop with max = 500
for i from 0 to max
collect (random max))))
(loop for i in random
counting (evenp i) into evens
counting (oddp i) into odds
summing i into total
maximizing i into max
minimizing i into min
finally (format t "Stats: ~A"
@Idorobots
Idorobots / gist:3378676
Created August 17, 2012 13:25
Simple Lisp grammar
(grammar ((Expression < (/ String List Atom)))
((String <- (:"\"") "[^\"]*" (: "\"")))
((List < (: "\\(") (* Expression) (: "\\)"))
`($(car List)
$(cdr List)))
((Atom <- (/ Number Symbol)))
((Number <- "[+\\-]?[0-9]+(\\.[0-9]*)?")
`($(car Number)
($(str->num (caadr Number)))))
((Symbol <- (! Number) "[^\\(\\)\"';\\s]+")
@Idorobots
Idorobots / somemusings.scm
Created February 8, 2021 15:41
Some stream-based continuation whatever I wrote a year ago and just only now found unfinished. 🤷
;; Stream Returning Converter
;; Assumes syntax & macro-expanded code.
(load "compiler/ast.scm")
(load "compiler/utils.scm")
(define (src expr source)
(cond ((define? expr) (src-define expr source))
((lambda? expr) (src-lambda expr source))
((if? expr) (src-if expr source))
@Idorobots
Idorobots / gist:3866870
Created October 10, 2012 16:53
Mode-line code
;; MODES
(require 'battery)
(setq battery-mode-line-format "#%b %p %t")
(setq battery-load-critical 7)
(setq battery-load-low 25)
(display-battery-mode t)
(require 'network-speed)
(setq network-speed-update-interval 5)
@Idorobots
Idorobots / streams.rkt
Last active June 20, 2019 19:56
Reactive streams?
(define-struct subscriber (on-subscription on-next on-error on-complete))
(define-struct subscription (on-request on-cancel))
(define-struct publisher (on-subscriber on-publish on-error on-complete))
(define (subscription on-request on-cancel)
(make-subscription on-request on-cancel))
(define (request sub n)
((subscription-on-request sub) n))
@Idorobots
Idorobots / gist:d04b599be1eec880b0d44325097d8fa5
Created December 20, 2018 14:38
"Hackduino" board configuration - an Arduino clone using a stock ATmega8.
hack.name=Hackduino
hack.vid.0=0x2341
hack.pid.0=0x0043
hack.vid.1=0x2341
hack.pid.1=0x0001
hack.vid.2=0x2A03
hack.pid.2=0x0043
hack.vid.3=0x2341
# enable
curl 'http://192.168.8.1/api/user/hilink_login' -H 'Pragma: no-cache' -H 'Origin: http://192.168.8.1' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: en-US,en;q=0.9' -H 'User-Agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.139 Mobile Safari/537.36' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'Accept: */*' -H 'Cache-Control: no-cache' -H 'X-Requested-With: XMLHttpRequest' -H 'Cookie: SessionID=+B+tlxt4VMFx4hXJ0Au2OPt/WZj+nDKA3zHSzViJq+mtzRMSzR/HXxYfddkk9Cqly11bArbDs7TUr9Dpuw+WqooU3SCNR+VQS7G5esdNtiWgKdu+lm16bgYWEcr3Thg4' -H 'Connection: keep-alive' -H 'Referer: http://192.168.8.1/html/modifypassword.html' -H '__RequestVerificationToken: bA5p+yJcEI2vBFF9R6EVRbWppMmW1vMr' --data '<?xml version="1.0" encoding="UTF-8"?><request><hilink_login>1</hilink_login></request>' --compressed
# disable
curl 'http://192.168.8.1/api/user/hilink_login' -H 'Pragma: no-cache' -H 'Origin: http://192.168.8.1' -H 'Acce

Keybase proof

I hereby claim:

  • I am Idorobots on github.
  • I am kajtek (https://keybase.io/kajtek) on keybase.
  • I have a public key whose fingerprint is 115F 54A0 0733 1F81 FBCD 8E4D 652F 6916 DD61 728E

To claim this, I am signing this object:

@Idorobots
Idorobots / gist:3379336
Created August 17, 2012 14:44
ASM reader to PEG correspondence
sequence: (A B C ...) => A B C ...
ordered choice: (/ A B C ...) => A / B / C / ...
optional branch: (? ...) => (...)?
zero or more: (* ...) => (...)*
one or more: (+ ...) => (...)+
not: (! ...) => !(...)
and (lookahead): (& ...) => &(...)
drop node: (: ...) - Drops a node from the parse tree.
concat captures: (~ ...) - Concatenates captures.
// SBT version 0.13.9
// Scala version 2.11.8
// Wartremover version 2.0.2
// Scalatest version 3.0.0
package warttest
import org.scalatest.{FunSpec, Matchers}
class WartAnySpec extends FunSpec with Matchers {