Skip to content

Instantly share code, notes, and snippets.

View nakkaya's full-sized avatar

Nurullah Akkaya nakkaya

View GitHub Profile
(defn +
"Returns the sum of nums. (+) returns 0. Does not auto-promote
longs, will throw on overflow. See also: +'"
{:inline (nary-inline 'add 'unchecked_add)
:inline-arities >1?
:added "1.2"}
([] 0)
([x] (cast Number x))
([x y] (. clojure.lang.Numbers (add x y)))
([x y & more]
@nakkaya
nakkaya / gist:3187737
Created July 27, 2012 12:42
Key Test
(ns key-test
(:import (java.awt.event KeyAdapter)
(javax.swing JFrame JPanel)))
(defn key-listener []
// PWM DIR BRE
int motors[4][3] = {{3, A0, A1}, //RF
{5, A2, A3}, //LF
{6, A4, A5}, //LR
{9, 4, 7}}; //RR
(let [w (search-world 640 480
[(vector-2d 100 100) 30]
[(vector-2d 200 200) 30]
[(vector-2d 300 200) 30]
[(vector-2d 400 300) 30]
[(vector-2d 280 350) 30]
[(vector-2d 250 200) 30])]
(defn print-a-star-test-table []
(print-table
@nakkaya
nakkaya / thread.c
Created May 30, 2011 15:12
evil_global
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
const int NUM_THREADS = 5;
pthread_mutex_t mutex;
int evil_global = 0;
void inc_evil_global(){
Desktop/ $ for ((n=0;n<10;n++)); do ./a.out; echo "------"; done
B
A
E
C
F
------
B
A
E
#include <sys/wait.h>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
int main(int argc, char *argv[]){
//write end [1] read end [0]
ABCDEFGH012345
./fgfs.sh --timeofday=morning --aircraft=c172p-2dpanel --shading-flat --disable-textures --geometry=640x480 --fog-disable --disable-horizon-effect --disable-clouds --generic=socket,out,40,localhost,6666,udp,output-protocol --generic=socket,in,45,127.0.0.1,6789,udp,input-protocol
[{:type :sequence, :name "Root"} [{:type :sequence, :name "Get Input"} [{:function "greeter.core/get-input!", :type :action, :name "Read input"}]] [{:type :selector, :name "How to Act on Input"} [{:type :sequence, :name "Greeting"} [{:function "greeter.core/is-greeting?", :type :action, :name "Is Greeting?"}] [{:function "greeter.core/already-greeted?", :type :action, :name "Not Already Greeted?"}] [{:function "greeter.core/send-greeting", :type :action, :name "Send Greeting"}]] [{:type :selector, :name "Question"} [{:type :sequence, :name "How are we feeling?"} [{:function "greeter.core/is-feeling?", :type :action, :name "feeling question?"}] [{:function "greeter.core/send-feeling-answer", :type :action, :name "Really Happy!"}]] [{:type :sequence, :name "What can we do?"} [{:function "greeter.core/is-abilities?", :type :action, :name "abilities question?"}] [{:function "greeter.core/send-abilities-answer", :type :action, :name "Absolutely Nothing!"}]]]]]