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
(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.
[Sat, 02 Jan 2010 21:47:53 GMT] [error] [<0.757.0>] ** Generic server couch_query_servers terminating
** Last message in was {'EXIT',<0.769.0>,
{{try_clause,
<<"Cannot encode 'undefined' value as JSON">>},
[{couch_query_servers,os_reduce,3},
{couch_query_servers,reduce,3},
{couch_view_group,'-init_group/4-fun-0-',4},
{couch_btree,'-write_node/3-lc$^0/1-0-',3},
{couch_btree,write_node,3},
{couch_btree,modify_node,4},
@zkat
zkat / gist:410336
Last active September 5, 2015 00:44
diff --git a/src/irc/channel.cpp b/src/irc/channel.cpp
index 0706767..23ee0bb 100644
--- a/src/irc/channel.cpp
+++ b/src/irc/channel.cpp
@@ -124,11 +124,11 @@ void Channel::sendNames(Nick* nick) const
string names;
for(vector<ChanUser*>::const_iterator it = users.begin(); it != users.end(); ++it)
{
- if(!names.empty())
- names += " ";
@zkat
zkat / gist:1073632
Last active September 26, 2015 09:08
urxvt color theme
URxvt*color0: #000000
URxvt*color1: #9e1828
URxvt*color2: #aece92
URxvt*color3: #968a38
URxvt*color4: #414171
URxvt*color5: #963c59
URxvt*color6: #418179
URxvt*color7: #bebebe
URxvt*color8: #666666
URxvt*color9: #cf6171
@zkat
zkat / gist:1193924
Created September 5, 2011 02:27
Password "hashing" in CL
(defparameter *key-derivation-iterations* 1056)
(defparameter *key-length* 32)
(defun hash-password (password salt)
"Password hashing function."
(ironclad:byte-array-to-hex-string
(ironclad:derive-key
(make-instance 'ironclad:pbkdf2 :digest :sha256)
(ironclad:ascii-string-to-byte-array password)
(ironclad:ascii-string-to-byte-array salt)
*key-derivation-iterations*
@zkat
zkat / gist:1225219
Last active September 27, 2015 06:18
Form builder example
(defclass account-name-field (email-field required-field) ())
(defmethod validate-field :after ((field account-name-field) account-name)
(check-field (not (find-account-by-email account-name))
"Account already exists."))
(defclass account-password-field (password-field required-field) ())
(defmethod validate-field :after ((field account-password-field) password)
(check-field (and (>= (length password) 6)
(every #'standard-char-p password))
"Password must be at least 6 characters long and can't contain funky characters."))
@zkat
zkat / gist:1239904
Created September 24, 2011 21:45
names
Valid names:
a/the little teapot
a/the little, short, and stout teapot
John Doe
Godot
Supreme Commander John Doe
Count Chocula
a/the captain of the guard
a/the male servant
@zkat
zkat / gist:1240098
Last active September 27, 2015 08:27
named entity test
(defun test-names ()
(flet ((test-case (expected modifier-alist)
(unwind-protect
(let ((e (create-entity :comment expected)))
(unwind-protect
(loop for (name . value) in modifier-alist
do (add-modifier e name value)
finally (assert (string= (full-name e) expected) ()
"Full name was ~S" (full-name e)))
(with-db ()
@zkat
zkat / gist:1240784
Last active September 27, 2015 08:27
git-grep in emacs
(defun git-grep (regexp)
(interactive "sSearch in git repo: ")
(grep (format "GIT_PAGER='' git grep -nH --no-color -i \"%s\" -- $(git rev-parse --show-toplevel)" regexp)))
(global-set-key (kbd "C-x ?") 'git-grep)