Skip to content

Instantly share code, notes, and snippets.

View y2q-actionman's full-sized avatar
🕹️
👾👾👾👾👾👾👾👾👾

Yokota Yuki y2q-actionman

🕹️
👾👾👾👾👾👾👾👾👾
View GitHub Profile
@y2q-actionman
y2q-actionman / trace1.txt
Created March 13, 2019 05:58
slime が時々通信に失敗して mode-line に数字が出たままになる。 slime-reset すると直るが・・
======================================================================
1 -> (slime-autodoc)
| 2 -> (slime-autodoc--parse-context)
| 2 <- slime-autodoc--parse-context: ("defun" "load-mock" ("config") ("declare" ("ignore" "config")) ("format" "*debug-io*" swank::%cursor-marker%))
| 2 -> (slime-autodoc--cache-get ("defun" "load-mock" ("config") ("declare" ("ignore" "config")) ("format" "*debug-io*" swank::%cursor-marker%)))
| 2 <- slime-autodoc--cache-get: nil
| 2 -> (slime-background-activities-enabled-p)
| | 3 -> (slime-current-connection)
| | 3 <- slime-current-connection: #<process SLIME Lisp>
| | 3 -> (slime-busy-p)
@y2q-actionman
y2q-actionman / emacs_slime_hangt.txt
Created March 7, 2019 03:34
ssh経由で slime が hang する件のメモ
;; 接続が失われた後で slime-auto-select-connection を拒否すると以下が出る。
Warning (slime): Caught error during fontification while searching for forms
that are suppressed by reader-conditionals. The error was: (error "No default connection selected.").
@y2q-actionman
y2q-actionman / fizzbuzz.c
Created January 31, 2019 10:03
C と lisp で fizzbuzz 比較
#include <stdio.h>
/*
int main() {
int i;
for (i = 1; i <= 100; ++i) {
if (i % 15 == 0) {
printf("FizzBuzz\n");
} else if (i % 3 == 0) {
@y2q-actionman
y2q-actionman / progv_test.lisp
Created January 25, 2019 09:25
progv を使って csv ヘッダを変数名として取り込んでループ回す
(in-package :cl-user)
(ql:quickload "split-sequence")
(defparameter *test-file* "/tmp/progv_test.csv")
(defun write-test-csv ()
(with-open-file (out *test-file* :direction :output :if-does-not-exist :create
:if-exists :rename)
(format out "col1,col2,col3~%")
@y2q-actionman
y2q-actionman / basic.c
Created January 11, 2019 08:46
最速 fizzbuzz に sendfile や tee を使おうと思ったけど、端末にはどちらも使えず pipe で cat とかに繋ぐ必要があって残念
#include <stdio.h>
#include <stdlib.h>
void __attribute__((noinline)) fizzbuzz_basic (void){
int i;
for (i = 1; i <= 100; ++i) {
if (i % 15 == 0) {
printf("FizzBuzz\n");
} else if (i % 3 == 0) {
printf("Fizz\n");
@y2q-actionman
y2q-actionman / TODO
Last active March 19, 2019 16:06
with-c-syntax backquote
* #{ -> ` -> #{ をネストできるように
* flet や handler-case や with-open-file で遊ぶと nest の例できそう
* struct 対応
* vacietis に触れる
@y2q-actionman
y2q-actionman / with-repl-variables.lisp
Last active June 21, 2019 02:35
repl 変数使えば anaphora いらんやん
(in-package :cl-user)
(defmacro with-repl-variables (&body body)
"BODY 中の式を、REPL 変数の `*', `+', `/', `-' 等を bind しながら順次実行する。"
(let ((form-results (gensym)))
`(let ((* *) (** **) (*** ***)
(+ +) (++ ++) (+++ +++) (- -)
(/ /) (// //) (/// ///))
,@(loop for form in body
collect
@y2q-actionman
y2q-actionman / progn-$_.lisp
Last active September 27, 2018 08:34
Common Lisp での Perl の $_ の適当実装
;;; 毎回 setf する (lambda と相性悪い)
(defmacro progn-$_ (&body forms)
`(let ($_)
,@(mapcar
(lambda (form)
`(setf $_ ,form))
forms)))
#|
CL-USER> (progn-$_ 1 2 3)
@y2q-actionman
y2q-actionman / power-assert.lisp
Last active September 27, 2018 07:31
Common Lisp での power-assert (30分で作った適当実装)
(in-package :cl-user)
(defmacro power-assert (form)
(assert (listp form))
(let ((op (first form))
(result (gensym))
binding
eval-form)
(assert (fboundp op) ()
"Operator must be fbound. (op is ~A)" op)
@y2q-actionman
y2q-actionman / game_read.lisp
Created September 14, 2018 18:47
land of lisp には game-read という関数があるらしい
;;; http://programcat.hatenablog.com/entry/2018/09/13/213126
(in-package :cl-user)
;;; この定義すごい!、というかパッと読めない・・
(defun game-read ()
(let ((cmd (read-from-string
(concatenate 'string "(" (read-line) ")"))))
(flet ((quote-it (x)
(list 'quote x)))