This file contains 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
(ns com.github.raek.events | |
(:use [clojure.contrib.core :only [dissoc-in]])) | |
(defn add-event-handler [state event-type key-or-agent f] | |
(assoc-in state [::handlers event-type key-or-agent] f)) | |
(defn remove-event-handler [state event-type key-or-agent] | |
(dissoc-in state [::handlers event-type key-or-agent])) | |
(defn dispatch-event [state event-type & args] |
This file contains 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
#include <iostream> | |
#include <iomanip> | |
#include <sstream> | |
#include <vector> | |
using namespace std; | |
int main() | |
{ | |
vector<double> v; |
This file contains 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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
#include <functional> | |
using namespace std; | |
class print_on: public binary_function<ostream&, int, void> | |
{ | |
public: |
This file contains 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
(defn pred-get | |
"Steps through all the keys in pred-map, which are mutually exclusive | |
predicates, finds the first one that returns true when passed expr, and | |
returs the value associated with that predicate. | |
(map #(pred-get {neg? -1, zero? 0, pos? 1} %) [5 -2 0]) => (1 -1 0)" | |
[pred-map expr] | |
(loop [preds (keys pred-map)] | |
(when-first [pred preds] | |
(if (pred expr) |
This file contains 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
;; By Rasmus Svensson. No copyright. | |
(ns pipes | |
(:import [java.io BufferedReader BufferedWriter] | |
[java.util.concurrent BlockingQueue LinkedBlockingQueue SynchronousQueue])) | |
(defprotocol Source | |
(take! [source] "Retrieves and removes the next object from the source.")) | |
(defprotocol Sink |
This file contains 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
.source Greeter.j | |
.class public Greeter | |
.super clojure/lang/AFn | |
.method public greeting(Ljava/lang/String;)Ljava/lang/String; | |
.limit stack 2 | |
.limit locals 2 | |
ldc "Good day, " | |
aload_1 | |
invokevirtual java/lang/String/concat(Ljava/lang/String;)Ljava/lang/String; |
This file contains 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
(add-to-list 'load-path "~/.emacs.d/") | |
;; clojure-mode | |
(add-to-list 'load-path "~/Projekt/clojure-mode") | |
(require 'clojure-mode) | |
;; swank-clojure | |
(add-to-list 'load-path "~/Projekt/swank-clojure") | |
(add-to-list 'load-path "~/Projekt/slime") |
This file contains 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
(ns konserver.swank-server | |
(:use [swank.swank])) | |
(swank.swank/ignore-protocol-version "2009-03-09") | |
(start-server ".slime-socket" :port 4005 :encoding "utf-8" :dont-close true) |
This file contains 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
(ns se.raek.bag | |
(:import [clojure.lang ILookup IPersistentSet])) | |
(defn- update | |
([map key f] | |
(assoc map key (f (get map key)))) | |
([map key not-found f] | |
(assoc map key (f (get map key not-found))))) | |
(deftype HashBag [map size] |
This file contains 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
(require 'paredit) | |
(eval-after-load 'paredit | |
'(progn (define-key paredit-mode-map (kbd "{") | |
'paredit-open-curly) | |
(define-key paredit-mode-map (kbd "}") | |
'paredit-close-curly) | |
(define-key paredit-mode-map (kbd "M-}") | |
'paredit-close-curly-and-newline))) |
OlderNewer