Skip to content

Instantly share code, notes, and snippets.

@mnzk
mnzk / addr.py
Last active October 19, 2017 08:45
template ='''
<html lang="ja">
<head>
<meta charset="UTF-8" />
<title>CANVAS001</title>
<link rel="stylesheet" type="text/css" href="v.css">
</head>
<body>
<div class="box-layer-1">
<div class="box box-left"><div class="from-blank-box"></div><div class="from-name vertical">蜿、隹キ謨ャ騾�</div><div class="from-address vertical">蜊玲袷邱丞クら區豬懃伴譬ケ譛ャ荳€蜈ォ荳€荳€</div><div class="from-post-number">2950104</div></div>
#lang racket
(require (only-in srfi/26 cute))
(define-syntax t>=
(syntax-rules ()
((_ x) x)
((_ x f g ...) (t>= (f x) g ...))))
(define (solve24 n)
#lang racket
(for ((lst (in-permutations (range 10)))
(i (in-range 5)))
(displayln `(,i ,lst)))
(require racket/generator)
(let ((g (sequence->generator (in-permutations (range 10)))))
@mnzk
mnzk / racket-class-generic.rkt
Created January 29, 2015 15:59
send と send-generic
#lang racket
(define sprite<%> (interface () draw))
(define draw (generic sprite<%> draw))
(define pix%
(class* object% (sprite<%>)
(super-new)
(define/public (draw)
'pix-draw)))
@mnzk
mnzk / spnz.js
Last active August 29, 2015 14:14
// spinoza for Nashorn shell (jjs)
// original code => https://github.com/kenokabe/spinoza
// [usage example]
//
// > jjs
// jjs> load("spnz.js")
// ===== spinoza =====
// jjs> world = $(1)(2)(3)(out)
// world-> 1,2,3
#lang racket
(provide mycompose1
mycompose)
(define-syntax mycompose1
(syntax-rules ()
((_) values)
((_ f1 f2 ...)
(lambda arglist (mycompose1$ arglist f1 f2 ...)))))
(System.Reflection.Assembly/LoadWithPartialName "System.Xml.Linq")
(ns linq.xml
(:import [System.Xml.Linq XDocument XElement XAttribute XNode])
(:import [System.IO MemoryStream StreamReader])
(:import [System.Text Encoding])
(:gen-class))
(defmacro ^:private local-name [node]
`(.. ~node Name LocalName))
(ns program
(:import System.IO.EndOfStreamException)
(:import clojure.lang.Compiler+CompilerException)
(:gen-class))
(defn try-eval [line v]
(let [v (conj v (str "\n" line))]
(try
[true (-> (apply str v) read-string eval) []]
(catch EndOfStreamException e [false nil v])
@mnzk
mnzk / draw-text-rotate.rkt
Last active August 29, 2015 14:11
draw-text における文字回転の例
#lang racket
(require racket/gui)
(define font (make-font #:size 40
#:size-in-pixels? #t
#:face "HGGyoshotai"))
(define font-size (send font get-point-size))
(define font-size-half (/ font-size 2))
(define rotate-text-hash '#hash(("ー" . #t)))