Skip to content

Instantly share code, notes, and snippets.

- (vec4_t)mapToSphere:(vec2_t)aWindowCoord // http://www.tommyhinks.com/docs/shoemake92_arcball.pdf
{
// normalize window coordinates
vec4_t viewport;
glGetFloatv(GL_VIEWPORT, viewport.f);
vec3_t p = { 2.0*aWindowCoord.x/viewport.z - 1.0, 2.0*aWindowCoord.y/viewport.w - 1.0, 0 };
// Map to sphere
float mag = p.x*p.x + p.y*p.y;
if(mag > 1.0) {
////////////////////////////////////////////////////////////////////////////////////////////
//
// PSClock
//
////////////////////////////////////////////////////////////////////////////////////////////
//
// Copyright (c) 2010, Fjölnir Ásgeirsson
//
// All rights reserved.
//
<?xml version="1.0" encoding="UTF-8"?>
<Module>
<ModulePrefs title="hello world example" />
<Content type="html"><![CDATA[
Hello, world!
]]></Content>
</Module>
@fjolnir
fjolnir / tlc.lua
Last active September 29, 2024 14:57
LuaJIT ObjC bridge
The bridge is now located at https://github.com/fjolnir/TLC
@fjolnir
fjolnir / gist:2235769
Created March 29, 2012 10:43
Objc method observer
objc = require("objc")
ffi = require("ffi")
setmetatable(_G, {__index=objc})
objc.debug=false
ffi.cdef("IMP class_replaceMethod(Class cls, SEL name, IMP imp, const char *types);")
local C = ffi.C
function observeMethod(class, sel, lambda)
local method = C.class_getInstanceMethod(class, SEL(sel))
if method == nil then
local _docTable = {}
function document(docStr)
return function(thingToDocument)
_docTable[thingToDocument] = docStr
end
end
document[[Adds documentation for a function]](document)
function help(thingToLookup)
@fjolnir
fjolnir / gist:2329407
Created April 7, 2012 14:36
Harmonograph to music
scene:clear()
count = 8000
scene.clearColor = rgb(0,0,0)
p1=buildParticles(count)
local x,y,Ax,wx,px,As,ws,ps,Ay,wy,py
Ax = 300.4
wx = 390.4
px = 123.9
Ay = 390.9
objc.class_setMetaTable({objc.NSDictionary, objc.__NSCFDictionary, objc.NSMutableDictionary, objc.__NSCFMutableDictionary }, {
__tostring = objc.objToStr,
__index = function(self, key)
local val = objc.getInstanceMethodCaller(self, "objectForKey_")(self, Obj(key))
if val ~= nil then
return val
end
return objc.getInstanceMethodCaller(self, key)
end,
__newindex = function(self, key, val)
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <dispatch/dispatch.h>
#include <readline/readline.h>
#include <stdio.h>
#include <objc/objc.h>
#include <objc/runtime.h>
#include <objc/objc-exception.h>
#include <stdlib.h>
#include <limits.h>
@class FString;
void uncaughtExceptionHandler(id e)