Skip to content

Instantly share code, notes, and snippets.

while (runMainLoop) {
while (SDL_PollEvent(&event)) {
if (event.type == SDL_QUIT) {
runMainLoop = false;
}
}
keystate = SDL_GetKeyState(NULL);
buttonstate = SDL_GetMouseState(&mousex, &mousey);
cont->mouseMove(mousex, mousey);
@aib
aib / gist:3203079
Created July 30, 2012 01:03
MCP should do this
From 1f17ce8262b1c5194e061819af8fe1e9a2bb15b6 Mon Sep 17 00:00:00 2001
From: aib <aibok42@gmail.com>
Date: Mon, 30 Jul 2012 04:00:34 +0300
Subject: [PATCH] Added mod source directories to their corresponding Eclipse projects.
---
eclipse/Client/.classpath | 2 ++
eclipse/Client/.project | 10 ++++++++++
eclipse/Server/.classpath | 2 ++
eclipse/Server/.project | 10 ++++++++++
(loop [last-tick-time (Sys/getTime)]
(let [current-time (Sys/getTime)
delta-seconds (- current-time last-tick-time)]
;tick game
(Display/update)
(if (not (should-quit?))
(recur current-time))))
(defn coll-eq
"Recursively applies a binary predicate to two colls (of colls etc.) and returns the AND of the result."
[eq-fn x y]
(let [all (partial every? identity)
all-eq (comp all (partial map (partial coll-eq eq-fn)))]
(if (and (coll? x) (coll? y))
(all-eq x y)
(eq-fn x y))))
(def vec== (partial coll-eq ==))
.global someHash
.set someHashL, 0x04030201
.set someHashH, 0x08070605
someHash: .long someHashL, someHashH
--
extern uint64_t someHash __asm__("someHash");
@aib
aib / glut.c
Last active December 11, 2015 12:29
GLUT [almost-]skeletal code
#include <GL/glut.h>
#include <time.h>
void reshape(int width, int height)
{
double aspect;
if (height == 0) height = 1;
aspect = width / height;
@aib
aib / gist:4739710
Created February 8, 2013 15:29
function painter
http://divisiblezero.github.com/functionPainter/?red=127.5+%2B+127.5*%28sin%28%28x^y%29+%2B+t%2F67*1.5%29%29&blue=127.5+%2B+127.5*%28sin%28%28x^y%29+%2B+t%2F61*1.5%29%29&green=127.5+%2B+127.5*%28sin%28%28x^y%29+%2B+t%2F71*1.5%29%29
@aib
aib / gist:47e41b50802bda25c9c8
Last active August 29, 2015 14:15
Java easy XML
//My notes on doing XML stuff in Java, as simply as possible
//not production quality, obviously
//XML parsing
DocumentBuilder db = null;
try {
db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
} catch (ParserConfigurationException e) {
}
@aib
aib / gist:5b29531a1e083e8b57ae
Last active August 29, 2015 14:16
PythonChallenge
let a0 = 2^38
let a1 = "lost in my ghci history"
let a2 = simpleHTTP (getRequest "http://www.pythonchallenge.com/pc/def/ocr.html") >>= getResponseBody >>= return . filter isAlpha
let a3 = simpleHTTP (getRequest "http://www.pythonchallenge.com/pc/def/equality.html") >>= getResponseBody >>= return . concatMap (!!1) . ((=~ "[^A-Z][A-Z]{3}([a-z])[A-Z]{3}[^A-Z]") :: String -> [[String]])
let a4_a = let dorq x = simpleHTTP (getRequest ("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" ++ x)) >>= getResponseBody in iterateUntilM (\x -> Debug.Trace.trace (show x) (not (x =~ "next nothing is")::Bool)) (dorq . last . words) "next nothing is 12345"
let a4_b = let dorq x = simpleHTTP (getRequest ("http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=" ++ x)) >>= getResponseBody in iterateUntilM (\x -> Debug.Trace.trace (show x) (not (x =~ "next nothing is")::Bool)) (dorq . last . words) "next nothing is 8022"
--
-- Table structure for table "site_cities"
--
DROP TABLE IF EXISTS "site_cities" CASCADE;
CREATE TABLE "site_cities" (
"city_id" serial NOT NULL,
"city_name" varchar(20) NOT NULL,
"plate_code" smallint NOT NULL,
"area_code" smallint NOT NULL,
"lat" decimal(20,8) NOT NULL,