Skip to content

Instantly share code, notes, and snippets.

View raek's full-sized avatar

Rasmus Bondesson raek

View GitHub Profile
#include <AStar32U4Prime.h>
const char key = '.';
Pushbutton buttonD(0);
void setup() {
Keyboard.begin();
}
void loop() {
if (buttonD.getSingleDebouncedPress()) { Keyboard.press(key); }
(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]
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
using namespace std;
int main()
{
vector<double> v;
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
class print_on: public binary_function<ostream&, int, void>
{
public:
(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)
;; 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
.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;
(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")
(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)
(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]