Skip to content

Instantly share code, notes, and snippets.

View youz's full-sized avatar
🈳
kyomu

Yōsuke Ushiki youz

🈳
kyomu
View GitHub Profile
@youz
youz / eshell.l
Created November 24, 2009 01:54
external shell settings for xyzzy
(require "shell3")
(in-package "editor")
(export '(exec-eshell *eshell-profiles*))
(defparameter *eshell-profiles*
`((:name "sbcl" :com "sbcl.bat" :prompt "^\\* ")
(:name "clisp" :com "clisp.bat" :prompt "^[\\[0-9\\]+]> ")
(:name "gosh" :com "gosh.exe -i" :encoding ,*encoding-utf8n*)
(:name "ypsilon" :com "ypsilon.bat")
@youz
youz / googl.l
Created December 18, 2009 09:39
goo.gl url shortener interface for xyzzy
;;; goo.gl url shortener interface for xyzzy
(eval-when (:compile-toplevel :load-toplevel :execute)
(require 'cmu_loop)
(require 'xml-http-request)
(require 'json)
(unless (find-package :googl)
(defpackage :googl
(:use :lisp :editor))))
@youz
youz / ldrpin.l
Created December 18, 2009 09:52
ldrpin mode for xyzzy
;;; -*- mode: lisp; package: ldrpin -*-
;;; ldrpin mode for xyzzy
(eval-when (:compile-toplevel :load-toplevel :execute)
(require 'xml-http-request)
(require 'json)
(require 'www/www)
(unless (find-package :ldrpin)
(defpackage :ldrpin
@youz
youz / gist:264591
Created December 28, 2009 08:37
expand-short-url #xyzzy
(require 'cmu_loop)
(defun expand-short-url (url)
(if (not (string-match "http://\\([^/]+\\)/\\(.+\\)" url))
url
(let ((host (match-string 1))
(path (match-string 2)))
(with-open-stream (cn (connect host 80))
(format cn "GET /~A HTTP/1.1\nHost: ~A\n\n" path host)
(let* ((res (read-line cn nil))
(m (string-match "^HTTP/[0-9.]+ \\([0-9]+\\) .+$" res))
@youz
youz / gist:276030
Created January 13, 2010 08:21
sogebu
;;; for xyzzy
(defun sogebu-region (from to &aux (text (buffer-substring from to)))
(interactive "r")
(with-input-from-string (is "H4sIAHp+TUsAA2t0aCQaKjSXa8Tlx2k2lyvUOXIRrw8GaxpPkKIrDkTqE9ShAHZTYxxhNyk0xmkoNDpowvgYGsAmKfT5w62PU2hsAamJR1gGZMcDlQBFNRrBFoPEm0FqoKJAWxQUuMCam9YqYLEFLAQAGz2QiHgBAAA=")
(insert (apply #'format nil (si:inflate-stream (si:base64-decode is))
(split-string (concat text "\n\n\n\n") #\LFD :ignore-empty nil)))))
@youz
youz / maze.arc
Created January 15, 2010 11:14
maze solver
;;; from http://okajima.air-nifty.com/b/2010/01/post-abc6.html
(= m (filechars "~/gists/maze_arc/maze.txt") ; or (drain:readc)
w (+ 1 (pos #\newline m))
a (n-of len.m nil)
(a:pos #\S m) '(0)
d 0
route)
(until route
@youz
youz / modanshogi.lisp
Created April 1, 2010 09:11
A CommonLisp Implementation of the programming language "ModanShogi".
;;; ref. http://github.com/yhara/ShogiModan
(eval-when (:compile-toplevel :load-toplevel :execute)
(unless (find-package :modanshogi)
(defpackage :modanshogi
(:use #+:xyzzy :lisp
#-:xyzzy :common-lisp))))
(provide 'modanshogi)
;;; http://www.itmedia.co.jp/enterprise/articles/1004/03/news002_2.html
#+xyzzy
(require 'cmu_loop)
;; utils
(defmacro aif (test then &optional else)
`(let ((it ,test)) (if it ,then ,else)))
(defmacro n-of (n expr)
@youz
youz / cairo-graph.lisp
Created April 20, 2010 10:04
making graphs with xyzzy-cairo
;;; ref. http://xyzzy.s53.xrea.com/wiki/index.php?%B4%D8%BF%F4%A4%CE%A5%B0%A5%E9%A5%D5%A4%F2%C9%BD%BC%A8%A4%B9%A4%EB
(require "cairo")
(use-package :cairo)
(defmacro draw-to-png
((cr filename &key (width 256) (height 256) (normalize t))
&body body)
`(progn
(when (file-exist-p ,filename)
@youz
youz / caret-macro.lisp
Created May 7, 2010 11:37
short aliases for lambda expression
;;; ref. http://blog.practical-scheme.net/gauche/20100428-shorter-names
;;; http://d.hatena.ne.jp/higepon/20100511/1273584001
#+:xyzzy
(require 'cmu_loop)
(defmacro ^ (args . body)
`(lambda ,args ,@body))
(defmacro define-caret-macros (chars)