This file contains hidden or 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
(defun port-available-p (port) | |
(handler-case (let ((socket (usocket:socket-listen "127.0.0.1" port :reuse-address t))) | |
(usocket:socket-close socket)) | |
(usocket:address-in-use-error (e) (declare (ignore e)) nil))) | |
;; Find port number not in use from 50000 to 60000. | |
(loop for port from (+ 50000 (random 1000)) upto 60000 | |
if (port-available-p port) | |
return port) |
This file contains hidden or 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
;; Push mark when using ido-imenu | |
(defvar push-mark-before-goto-char nil) | |
(defadvice goto-char (before push-mark-first activate) | |
(when push-mark-before-goto-char | |
(push-mark))) | |
(defun ido-imenu-push-mark () | |
(interactive) |
This file contains hidden or 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
(defun ido-imenu () | |
"Update the imenu index and then use ido to select a symbol to navigate to. | |
Symbols matching the text at point are put first in the completion list." | |
(interactive) | |
(imenu--make-index-alist) | |
(let ((name-and-pos '()) | |
(symbol-names '())) | |
(flet ((addsymbols (symbol-list) | |
(when (listp symbol-list) | |
(dolist (symbol symbol-list) |
This file contains hidden or 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
;;; Original URL: http://fpn.mit.edu/Downloads/SuffixTree | |
;;; Copyright [email protected] 2004. | |
(defpackage :suffix-tree | |
(:export :build-suffix-tree :stree-root :*stree-print-string* | |
:random-string :subtree-size :count-leaves) | |
(:use :common-lisp)) | |
;; An O(n) implementation of McCreight's suffix-tree algorithm. | |
;; Usage example: |
This file contains hidden or 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
(import 'clack.request:make-request 'clack.request:body-parameter) | |
(clack:clackup | |
#'(lambda (env) | |
(format t "~S~%" | |
(body-parameter (make-request env))) | |
'(200 | |
(:content-type "text/html") | |
("<form method='POST' enctype='multipart/form-data'><input type='file' name='pdf'><input type='submit'></form>")))) |
This file contains hidden or 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
(import 'clack.request:make-request 'clack.request:body-parameter) | |
(clack:clackup | |
#'(lambda (env) | |
(format t "~S~%" | |
(body-parameter (make-request env))) | |
'(200 | |
(:content-type "text/html") | |
("<form method='POST' enctype='multipart/form-data'><input type='file' name='pdf'><input type='submit'></form>")))) |
This file contains hidden or 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
;;;; -*- Mode: Lisp -*- | |
;;;; http://pastebin.com/S1FzEZpn | |
;; | |
;; vim: filetype=lisp | |
(in-package :stumpwm) | |
;; Load swank. | |
;; ! what's this? | |
(load "/opt/quicklisp/dists/quicklisp/software/slime-20120307-cvs/swank-loader.lisp") |
This file contains hidden or 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
#!/bin/bash | |
read -s -p "GitHub password: " pass | |
# I assume the GitHub API and authentication works because I don't want to parse JSON | |
curl -u "yefim323:$pass" https://api.github.com/user/repos -d "{\"name\":\"$1\"}" > /dev/null | |
git remote add origin [email protected]:yefim323/$1.git |
This file contains hidden or 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
;; http://www.jasq.org/2/post/2012/05/inverse-fizzbuzz.html | |
;; http://d.hatena.ne.jp/matarillo/20120515/p1 | |
#.(progn | |
(ql:quickload :optima) | |
(ql:quickload :alexandria) | |
(ql:quickload :cl-test-more) | |
(values)) | |
(setq *print-circle* t) |
This file contains hidden or 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
Latency Comparison Numbers (~2012) | |
---------------------------------- | |
L1 cache reference 0.5 ns | |
Branch mispredict 5 ns | |
L2 cache reference 7 ns 14x L1 cache | |
Mutex lock/unlock 25 ns | |
Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
Compress 1K bytes with Zippy 3,000 ns 3 us | |
Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |