Skip to content

Instantly share code, notes, and snippets.

View lokedhs's full-sized avatar

Elias Mårtenson lokedhs

View GitHub Profile
This file has been truncated, but you can view the full file.
(declaim (optimize (safety 3) (speed 0) (debug 3)))
(defparameter *rbtree-special-test-data*
'((:INSERT (720255619831889/500000 . 1))
(:INSERT (180063904958453/125000 . 101))
(:INSERT (1440511239667639/1000000 . 102))
(:INSERT (720255619833821/500000 . 103))
(:INSERT (1440511239667643/1000000 . 104))
(:INSERT (360127809916911/250000 . 105))
(:INSERT (720255619833823/500000 . 106))
em-desktop$ sbcl
This is SBCL 1.1.15.39-4878c26, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.
SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses. See the CREDITS and COPYING files in the
distribution for more information.
* (ql:quickload "iolib")
To load "iolib":
@lokedhs
lokedhs / couchdb_benchmarks
Created October 5, 2014 10:10
Benchmark of clouchdb with and without HTTP keepalive
elias@tiger:~/prog/clouchdb$ ab -n 100 'http://127.0.0.1:5984/foo'
This is ApacheBench, Version 2.3 <$Revision: 1528965 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: CouchDB/1.6.0
Server Hostname: 127.0.0.1
@lokedhs
lokedhs / simplex noise
Created March 13, 2015 07:21
Simplex noise generator
(defun make-simplex-noise-generator ()
(flet ((dot-prod (g x y)
(declare (optimize (speed 3) (safety 1))
(type (simple-vector 3) g)
(type double-float x y))
(+ (* (the (double-float -1d0 1d0) (aref g 0)) x)
(* (the (double-float -1d0 1d0) (aref g 1)) y))))
(let ((grad3 #(#(1d0 1d0 0d0) #(-1d0 1d0 0d0) #(1d0 -1d0 0d0) #(-1d0 -1d0 0d0)
#(1d0 0d0 1d0) #(-1d0 0d0 1d0) #(1d0 0d0 -1d0) #(-1d0 0d0 -1d0)
(defpackage :clctest
(:use :cl))
(in-package :clctest)
(defparameter *test-values1*
'((:INSERT (90024546449273/62500 . 1))
(:REMOVE (90024546449273/62500 . 1))
(:INSERT (720196371606183/500000 . 2))
(:REMOVE (720196371606183/500000 . 2))
(defclass rbt-empty-node (red-black-node)
())
(defmethod (setf rbt-color) (new-value (obj rbt-empty-node))
(error "Empty nodes can't be changed"))
(defmethod (setf left-child) (new-value (obj rbt-empty-node))
(error "Empty nodes can't be changed"))
(defmethod (setf right-child) (new-value (obj rbt-empty-node))
clang-linux.compile.c++.without-pth ../../src/main/bin/clang-linux-linux/release/gc-boehm/program-clasp/corePackage.o
In file included from ../../src/core/corePackage.cc:62:
In file included from ../../include/clasp/main/generated/initClasses_inc.h:247:
In file included from /home/emartenson/src/clasp/src/asttooling/include/astVisitor.h:30:
In file included from /usr/include/clang/AST/RecursiveASTVisitor.h:17:
In file included from /usr/include/clang/AST/Attr.h:18:
In file included from /usr/include/clang/AST/Decl.h:17:
In file included from /usr/include/clang/AST/APValue.h:21:
In file included from /usr/include/llvm/ADT/PointerUnion.h:18:
In file included from /usr/include/llvm/ADT/DenseMapInfo.h:17:
@lokedhs
lokedhs / mandelbrot.sh
Last active December 13, 2015 22:29
A version of mandelbrot.sh originally written by Benjamin Staffin here: https://gist.github.com/benley/4984040 This version is plain "sh" without any bash-specific code. You have to be extremely patient to actually run it.
#!/bin/sh
#
# Mandelbrot in plain sh without any bash-specific features
#
# Original version by Benjamin Staffin:
# https://gist.github.com/benley/4984040
#
L=99
P=100000000
@lokedhs
lokedhs / gist:5270622
Created March 29, 2013 12:49
How to get CN from an SSL connection
(usocket:with-client-socket (socket stream "encrypted.google.com" 443)
(let* ((enc (cl+ssl:make-ssl-client-stream stream))
(crypto (cl+ssl::ssl-stream-handle enc))
(cert (cl+ssl::ssl-get-peer-certificate crypto))
(subj (cl+ssl::x509-get-subject-name cert)))
(format t "entry count: ~s~%" (cl+ssl::x509-name-entry-count subj))
(cffi:with-foreign-pointer (buf 10240)
(let ((result (cl+ssl::x509-name-get-text-by-nid subj 13 buf 10240)))
(if (= result -1)
(format t "Could not find nid~%")
(function (doc) {
return doc.type === 'user_notification' && !doc.read && doc.ping_timestamp != null ? emit(doc.ping_timestamp, [doc.user]) : null;
});
(function (key, values, rereduce) {
var result = { };
for (var value = null, _js_idx1 = 0; _js_idx1 < values.length; _js_idx1 += 1) {
value = values[_js_idx1];
for (var uid = null, _js_idx2 = 0; _js_idx2 < value.length; _js_idx2 += 1) {
uid = value[_js_idx2];