Skip to content

Instantly share code, notes, and snippets.

@Yoxem
Yoxem / test.sil
Last active March 4, 2018 18:16
Hokkien test of SILE
\begin[class=jplain]{document} % test.sil,註跤建議用「半型空白+%」做起頭,佮 LaTeX 仝款。用 jplain 逝kap逝的空間才會大
\font[family=AR PL UMing TW,language=ja] % 假使有安裝 AR PL UMing TW 這个字型。中文主動換逝的功能無支援,姑不而將用日語ê
\script[src=packages/ruby] %試ruby 加注音
%巴克禮聖經(漢羅轉寫)
\font[size=24pt]{創世紀}\par
原起頭上帝創造天kap地。地是空空混沌,深淵ê面上烏暗;上帝ê神運動tī水面。
上帝講,tio̍h有光,就有光。上帝看光,是好;上帝將光暗分開。上帝叫hit ê光做日,叫暗做暝。有下昏有早起,是頭一日。
@Yoxem
Yoxem / cps.scm
Last active February 19, 2018 12:33
A demo of continuation-pass-style (CPS) by finding the n-th number of fibonacci series with R5RS Scheme.
;; a demo of continuation-pass-style by finding the n-th number of fibonacci series.
;; works in R5RS scheme
(define +&
(lambda (a b y)
(y (+ a b)
)))
(define <&
(lambda (a b y)
@Yoxem
Yoxem / call-cc.scm
Last active July 27, 2018 20:27
A simple example of call/cc (call-with-current-continuation)
(define (g x)
(display "萬歲")
(cos (x 18))(x 20)
(display "ura")
72
)
(call-with-current-continuation g)
;; prints 萬歲; then returns 18
(g cos)
@Yoxem
Yoxem / linewrap.py
Last active January 28, 2018 18:47
a probably buggy line-wrapping test script try to mininize the badness (like the algorithm by D.E.Knuth)
#!/usr/bin/env python3
#-*-coding:utf-8-*-
from PIL import ImageFont
font_path = "/usr/share/fonts/truetype/freefont/FreeSerif.ttf"
font_size = 15
line_width = 360 # in px
font = ImageFont.truetype(font_path, font_size)
@Yoxem
Yoxem / huge_number_calc.rs
Created January 24, 2018 14:59
huge_number_calc.rs - a program to count (add/sub/mul/div (quotient)/remainder) with signed huge numbers.
/* huge_number_calc.rs - a program to count (add/sub/mul/div (quotient)/remainder) with signed huge numbers.
Copyright (C) 2018 Yoxem Chen <chenjt30 #AT# gmail {DoT} com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@Yoxem
Yoxem / define-syntax-and-syntax-rules-example.scm
Last active January 24, 2018 17:40
scheme 系 (define-syntax) (syntax-rule) 的用法舉隅
;; #lang r5rs -> scheme R5Rs
;; scheme 系 (define-syntax) (syntax-rule) 的用法舉隅(有關巨集 macro)
;;; 求算平方和,sqrt-num 是巨集名稱
;; 期望輸出結果
; (sqrt-sum 2) => 4 (回傳值,= 2^2)
; (sqrt-sum 1 3) => 10 (=1^2+3^2)
; (sqrt-sum 1 3 5) => 35 (=1^2+3^2+5^2)
(define-syntax sqrt-sum
(syntax-rules ()
@Yoxem
Yoxem / interpreter.py
Last active January 9, 2018 14:56
A lisp-like list "interpreter"
def add(a,b):
return a + b
def exe(x):
if type(x) in [int, float, bool]:
return x
elif x[0] == "if_":
if exe(x[1]) == True:
return exe(x[2])
else:
@Yoxem
Yoxem / index.html
Last active July 17, 2017 16:31
A test on a Sozi (a plugin of Inkscape) SVG-presentation embedded in a HTML webpage with <object>
<!DOCTYPE html>
<html>
<!-- ref.: http://sozi.baierouge.fr/pages/tutorial-embedding.html -->
<meta charset="utf-8">
<body style="color:rgb(10,10,100)">
<h1 style="color:rgb(30,30,230);">高橋流 Sozi 簡報內嵌於網頁的測試</h1>
<strong>想像的共同體心得(?)</strong><p/>
請用滑鼠點選方框內切換頁面。
<p/>
<object height="400px" width="50%" style="box-shadow: 2px 2px 4px 2px rgba(0,0,150,0.4);margin-left:25%;"
@Yoxem
Yoxem / cairo-text-example.py
Created April 2, 2017 12:50
a test for output text by pycairo
#!/usr/bin/env python3
#under MIT license
#by yoxem 2017-04-02
import cairo
#設定寬高
#setting the width and height in inches.
#width of a4 = 8.3 inch = 8.3*72px
#height of a4 = 8.3 inch = 8.3*72px
WIDTH, HEIGHT = (8.3 * 72), (11.7 * 72)
@Yoxem
Yoxem / stagecoach-problem.rkt
Last active April 2, 2017 07:59
20170402 - stagecoach-problem.rkt used to solve stagecoach problem.
#lang racket
;; 20170402 - stagecoach-problem.rkt used to solve stagecoach problem.
;; license: MIT license
;; by Yoxem
;; cost table from O to D with cost in 2D hash-tables
(define cost-table