Skip to content

Instantly share code, notes, and snippets.

(def sudoku-board [[5 3 0 0 7 0 0 0 0]
[6 0 0 1 9 5 0 0 0]
[0 9 8 0 0 0 0 6 0]
[8 0 0 0 6 0 0 0 3]
[4 0 0 8 0 3 0 0 1]
[7 0 0 0 2 0 0 0 6]
[0 6 0 0 0 0 2 8 0]
[0 0 0 4 1 9 0 0 5]
[0 0 0 0 8 0 0 7 9]])
(define-generic-mode 'ebnf-mode
'(("(*" . "*)"))
'("=" ":" ":=" "::=")
'(
("^[^ \t\n][^=]+" . font-lock-variable-name-face)
("<" . font-lock-constant-face)
(">" . font-lock-constant-face)
("['\"].*?['\"]" . font-lock-string-face)
("\\[\\|\\]\\|{\\|}\\|(\\|)\\||\\|,\\|;" . font-lock-type-face)
("\\?" . font-lock-builtin-face)
user> (defmacro fundef [a b]
`(defn ~(symbol (str "plus-" a "-" b)) [arg#] (+ ~a ~b arg#)))
#'user/fundef
user> (fundef 1 2)
#'user/plus-1-2
user> (plus-1-2 3)
6
user> (map #(fundef %1 %2) (range 3) (range 3))
(#'user/plus-p1__10068#-p2__10069# #'user/plus-p1__10068#-p2__10069# #'user/plus-p1__10068#-p2__10069#)
user> (plus-0-0 1)
@luxbock
luxbock / core.clj
Created September 21, 2014 12:00
lein-plz-nicknames
(ns lein-plz-nicknames
"Tiny script to check for additional projects discovered by crawling
crossclj.info and filtering for the popularity of the project."
(:require [me.raynes.laser :as l]
[clojure.string :as str]
[leiningen.plz :refer [fallback-nicknames]]))
(def prj-from-crossclj
"Fetches a list of projects from crossclj.info"
(apply str
@luxbock
luxbock / anonymous-gist.clj
Created September 24, 2014 18:43
data-readers weirdness
(deftype Bar [a]
Object
(equals [self other] true)
(toString [_] (str a)))
(defn barme [a] (->Bar a))
(set! *data-readers* {'bar myns/barme})
;; #bar :foo => nil
@luxbock
luxbock / clj-imenu.el
Last active August 29, 2015 14:06
clojure imenu support
(setq clojure-imenu-generic-expression
'((nil "^\\s-*(\\(?:s\\|t/\\)?defn-?\\s-+\\(?:\\^[^[:space:]\n]+\\s-+\\)?\\([^[:space:]\n]+\\)" 1)
("Variable""^\\s-*(\\(?:s\\|t/\\)?def[[:space:]\n]+\\(?:\\(?:\\^{[^}]+}[[:space:]\n]+\\)\\|\\(?:\\^:[^[:space:]\n]+\\s-+\\)\\)?\\([^[:space:]\n\)]+\\)" 1)
("Macro" "^\\s-*(defmacro\\s-+\\([^[:space:]\n]+\\)" 1)
("Record" "^\\s-*(\\(?:s/\\)?defrecord\\s-+\\([^[:space:]\n]+\\)" 1)
("Type" "^\\s-*(deftype\\+?\\s-+\\([^[:space:]\n]+\\)" 1)
("Protocol" "^\\s-*(\\(?:def\\(?:-abstract-type\\|interface\\+?\\|protocol\\)\\)\\s-+\\([^[:space:]\n]+\\)" 1)
("Multimethod" "^\\s-*(defmulti\\s-+\\([^[:space:]\n]+\\)" 1)
("Multimethod" "^\\s-*(defmethod\\s-+\\([^[:space:]\n]+\\)" 1)))
~/Google Drive/projects/demo_app $ mono SubgameConsole.exe
SubgameConsole - type ? for help
Unhandled Exception:
System.DllNotFoundException: libsubgame
at (wrapper managed-to-native) SubgameConsole.libsubgame:libsubgame_init (int)
at SubgameConsole.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.DllNotFoundException: libsubgame
at (wrapper managed-to-native) SubgameConsole.libsubgame:libsubgame_init (int)
at SubgameConsole.Program.Main (System.String[] args) [0x00000] in <filename unknown>:0
@luxbock
luxbock / asdfsf
Created October 3, 2014 15:35
hhh
Mono: DllImport error loading library '/Users/Olli/Google Drive/projects/demo_app/libsubgame.dylib': 'dlopen(/Users/Olli/Google Drive/projects/demo_app/libsubgame.dylib, 9): image not found'.
Mono: DllImport error loading library '/Users/Olli/Google Drive/projects/demo_app/libsubgame.so': 'dlopen(/Users/Olli/Google Drive/projects/demo_app/libsubgame.so, 9): no suitable image found. Did find:
/Users/Olli/Google Drive/projects/demo_app/libsubgame.so: unknown file type, first eight bytes: 0x7F 0x45 0x4C 0x46 0x02 0x01 0x01 0x00'.
@luxbock
luxbock / crypto-coursera.org
Created October 3, 2014 16:07
crypto-notes
@luxbock
luxbock / asdfdsf.clj
Last active August 29, 2015 14:07
scen-c results
(def scen-c
{:algorithm 0
:abstraction 0
:rules {:stack 1000, :pot 100, :bb 20, :to-act 0
:max-bets 3 :actions [[1/2 3/4 1 :all-in] [1/2 1 :all-in]]}
:init-node {:player 1, :prev-action :check, :street 3}
:board [(card "2h") (card "3s") (card "4d") (card "Ts")]
:range-sb (hand-range "5s5h 6s5s 7c2h Th9h 9c9s AcAd KsKd")
:range-bb (hand-range "AcAd AsAh AdAh AsAd 7c9h")})