This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (artanis server epoll) | |
(artanis utils) | |
(ice-9 rdelim) | |
(ice-9 match) | |
(ice-9 suspendable-ports) | |
(ice-9 control)) | |
(install-suspendable-ports!) | |
(define (call-with-sigint x y) (%call-with-sigint x y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define (make-lru size) | |
(define cnt 0) | |
(define fl '()) | |
(define ht (make-hash-table)) | |
(define (refresh-fl i) | |
(set! fl (cons i (filter (lambda (x) (not (= x i))) fl)))) | |
(lambda (cmd . i/v) | |
(case cmd | |
((get) | |
(refresh-fl (car i/v)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 match)) | |
(define (cl str) | |
(define (parser s) | |
(let lp((i 0) (ret '())) | |
(cond | |
((= i (string-length s)) | |
(map (lambda (x) | |
(if (char? x) (string->symbol (string x)) x)) | |
(reverse ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;==============Tiny framework of Actor-model========================= | |
(use-modules (ice-9 control) (ice-9 match) (ice-9 q)) | |
(define *mailbox* (make-hash-table)) | |
(define *task-queue* (make-q)) | |
(define (gen-pid n) (gensym (format #f "actor-~a-" n))) | |
(define-syntax-rule (! pid msg) | |
(let ((mq (hashq-ref *mailbox* pid))) | |
(if mq |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env guile | |
!# | |
(use-modules (ice-9 rdelim) | |
(ice-9 ftw) | |
(ice-9 futures) | |
(srfi srfi-1)) | |
(define get-string-all (@ (rnrs io ports) get-string-all)) | |
(define G (ash 1 30)) | |
(define M (ash 1 20)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 rdelim))(define morse '((#\a ".-")(#\b "-...")(#\c "-.-.")(#\d "-..")(#\e ".")(#\f "..-.")(#\g "--.")(#\h "....")(#\i "..")(#\j ".---")(#\k "-.-")(#\l ".-..")(#\m "--")(\ | |
#\n "-.")(#\o "---")(#\p ".--.")(#\q "--.-")(#\r ".-.")(#\s "...")(#\t "-")(#\u "..-")(#\v "...-")(#\w ".--")(#\x "-.--")(#\y "-.--")(#\z "--..")))(for-each (lambda (x) (if (char-alphabetic\ | |
? x)(display (car (assoc-ref morse x))))(display " "))(string->list (string-downcase (read-line (current-input-port)))))(newline) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-modules (ice-9 rdelim) (rnrs)) | |
(define (k f init val pred) | |
(if (pred val) | |
init | |
(call-with-values (lambda () (f init val)) | |
(lambda (lst rst) (k f lst rst pred))))) | |
(define (lexer str delimiters) | |
(define (-> c) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from PIL import Image, ImageDraw | |
import time, os, sys | |
ori, des = sys.argv[1:] | |
im = Image.open(ori) | |
draw = ImageDraw.Draw(im) | |
textPadding = 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(define-syntax sets! | |
(syntax-rules () | |
((_ (var) (val)) | |
(set! var val)) | |
((_ (var vars* ...) (val vals* ...)) | |
(let ((var0 val)) | |
(sets! (vars* ...) (vals* ...)) | |
(set! var var0))))) |
NewerOlder