Skip to content

Instantly share code, notes, and snippets.

View zkat's full-sized avatar
💭
Rusting it up

Kat Marchán zkat

💭
Rusting it up
View GitHub Profile
@zkat
zkat / gist:5176
Last active August 29, 2015 14:34
(defun preparse-adverbs (token-list) ;This is the worst way to handle this shit. Ever. Temporary. Very.
"Yoinks all the adverbs it recognizes out of a list.
MULTIPLE RETURN VALUES: The first adv it finds, and a token-list purified of this evil."
(if (> (length token-list) 1)
(let ((adverb (find-if #'adverb-p token-list)))
(if adverb
(let ((token-list (remove-if #'adverb-p token-list :count 1)))
(values adverb token-list))
(values adverb token-list)))
(values nil token-list)))
@zkat
zkat / gist:5343
Last active August 29, 2015 14:34
SYKOSOMATIC> (setf *test-hash* (make-hash-table))
#<HASH-TABLE :TEST EQL :COUNT 0 {AB4EF51}>
SYKOSOMATIC> (setf (gethash "testing" *test-hash*) "testing")
"testing"
SYKOSOMATIC> *test-hash*
#<HASH-TABLE :TEST EQL :COUNT 1 {AB4EF51}>
SYKOSOMATIC> (gethash (string-downcase "TESTING") *test-hash*)
NIL
@zkat
zkat / gist:5533
Last active August 29, 2015 14:35
<rooms>
<room>
<name> Room 1 </name>
<desc> room 1's desc </desc>
<desc-long> room 1's long description </desc-long>
<features>
<feature>
<name> room 1's feature </name>
<desc> ... </desc>
(defun slate-dispatch (selector &rest args)
(let ((n (length args))
(most-specific-method nil)
(ordering-stack nil))
(loop for index upto n
do (let ((position 0))
(push (elt args index) ordering-stack)
(loop while ordering-stack
do (let ((arg (pop ordering-stack)))
(loop for role in (roles arg)
@zkat
zkat / gist:49352
Last active August 29, 2015 21:45
;dispatch(selector, args, n)
; for each index below n
; position := 0
; push args[index] on ordering stack
; while ordering stack is not empty
; arg := pop ordering stack
; for each role on arg with selector and index
; rank[role's method][index] := position
; if rank[role's method] is fully specified
; if no most specific method
(setq current-cl-package "COMMON-LISP-USER")
(defun erc-cmd-CLPACKAGE (&optional package &rest ignore)
(when package
(setq current-cl-package (upcase package)))
(erc-send-message (format "CL Package is: %s" current-cl-package)))
(defun erc-cmd-EVAL (&rest form)
"Eval FORM and send the result and the original form as:
FORM => (eval FORM)."
(let* ((form-string (mapconcat 'identity form " "))
(defbuzzword create-texture (texture))
(defbuzzword bind-texture (texture))
(defbuzzword delete-texture (texture))
(defbuzzword reload-texture (texture))
(defsheep =texture= ()
((name nil)
(target :texture-2d)))
(defmessage bind-texture ((texture =texture=))
SHEEPLE> (sb-sprof:with-profiling (:report :flat :max-samples 500)
(dotimes (i 2000) (clone () ())))
Profiler sample vector full (155 traces / 5000 samples), doubling the size
Profiler sample vector full (309 traces / 10000 samples), doubling the size
Number of samples: 500
Sample interval: 0.01 seconds
Total sampling time: 5.0 seconds
Number of cycles: 0
Sampled threads:
(defmessage draw ((engine =test-engine=))
(declare (ignore engine))
(dotimes (i 100)
(draw (clone (=component=)
((x (random 400))
(y (random 400))
(width 10)
(height 10))))))
;; 22fps from this:
<?php
/**
* latest_github_commits.php
* Dumps a github commit report.
*/
/**
* Dump a report of the latest commits for a github repo.
*
* @param string $owner Account name that owns the repo in question.