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
#if 0 | |
echo Compiling... | |
cc -Wall -g -std=c99 $0 -o 2016-04-13 && ./2016-04-13 | |
exit | |
#endif | |
#include <stdlib.h> | |
#include <stdio.h> | |
#include <assert.h> | |
#include <string.h> |
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 <stdio.h> | |
#include <stdlib.h> | |
#include <pthread.h> | |
#include <assert.h> | |
#include <libkern/OSAtomic.h> | |
#include <unistd.h> | |
typedef void(*WorkFunction)(void* work_data); |
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 <stdlib.h> | |
#include <stdio.h> | |
#include <time.h> | |
#include <pthread.h> | |
#define TEST_CASES 1000000 | |
#define TEST_RUNS 30 | |
// Channels for passing data between threads. We pack a whole cache line of ints before |
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 <stdlib.h> | |
int main(int nargs, char * args[]) | |
{ | |
void* vp = malloc(sizeof(char) * 5); | |
const char* ip = (char*)(vp); | |
free(ip); | |
} |
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
#lang racket | |
(define (get-spaces-inner n spaces) | |
(define current-space (car spaces)) | |
(if (> current-space n) | |
(cdr spaces) | |
(get-spaces-inner n (cons (* current-space 2) spaces)))) | |
(define (get-spaces n) | |
(get-spaces-inner n '(1))) |
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 goup-engine.core | |
(:import (com.jme3.app SimpleApplication) | |
(com.jme3.material Material) | |
(com.jme3.math ColorRGBA) | |
(com.jme3.math Vector3f FastMath Quaternion) | |
(com.jme3.renderer RenderManager) | |
(com.jme3.scene Geometry Node) | |
(com.jme3.scene.shape Box Quad) | |
(com.jme3.input KeyInput) | |
(com.jme3.input.controls KeyTrigger ActionListener) |
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 saolsen.particles-simulate | |
(:require [saolsen.draw-2d :as draw])) | |
;; Simple simulated neutonian physics. | |
(defn integrate-particle | |
"Moves the particle a distance based on it's velocity | |
P = P + V*dt | |
Simple collisions with walls reverse velocity. | |
Returns a new particle. | |
" |
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 saolsen.draw-2d) | |
;; Draw stuff (and never care about ie ever) | |
;; There's obviously a ton this lib doesn't do, just adding what | |
;; I need when I need it. | |
(def request-animation-frame | |
(or js/requestAnimationFrame | |
js/webkitRequestAnimationFrame)) | |
(defn get-canvas-context-from-id |
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 game.macros.profiling) | |
;; Must require this and also | |
;; (:use [game.profiling :only [start-time! stop-time!]]) | |
(defmacro profile | |
"Wraps the body in the game.profiling calls" | |
[function-name & body] | |
`(let [profile# (start-time! ~function-name) | |
result# ~@body] |
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 reducer | |
;; Removes 5 and the item after it from a sequence. | |
[{:keys [flag seq]} item] | |
(cond | |
flag {:flag false :seq seq} | |
(= item 5) {:flag true :seq seq} | |
:else {:flag false :seq (conj seq item)})) | |
(:seq (reduce reducer {:flag false :seq []} [1 2 3 4 5 6 7 8 9 10])) |