Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris dennda

View GitHub Profile
View gist:500986
diff --git a/Library/Formula/opencv.rb b/Library/Formula/opencv.rb
index 8249202..94da337 100644
--- a/Library/Formula/opencv.rb
+++ b/Library/Formula/opencv.rb
@@ -22,7 +22,9 @@ class Opencv <Formula
# There are other optional dependencies but they don't currently exist in Homebrew.
def install
- system "cmake -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=#{prefix} ."
+ makefiles = "cmake -G 'Unix Makefiles' -DCMAKE_INSTALL_PREFIX:PATH=#{prefix} ."
View gist:811351
#!/usr/bin/env python
# Import VTK with special EmbedOpenGL renderer
import os
os.environ['VTK_RENDERER'] = 'EmbedOpenGL'
import vtk
import time
from pymt import *
from OpenGL.GL import *
View gist:1198272
- (void) setupSockets {
void* info = (__bridge void*) self;
readsock = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM,
IPPROTO_UDP, kCFSocketReadCallBack |
kCFSocketAcceptCallBack | kCFSocketDataCallBack |
kCFSocketConnectCallBack | kCFSocketWriteCallBack,
(CFSocketCallBack)readSockCallBack, info);
....
}
View gist:1202327
GLfloat* createSlices(unsigned int num_slices) {
// Each slice has 4 vertices (GL_TRIANGLE_STRIP)
unsigned long total_verts = num_slices * 4;
// Each vertex has 3 coordinates
unsigned long total_elements = total_verts * 3;
// We have 4 verts * 3 coords = 12 elements per slice
const GLfloat one_slice[12] = {
// x, y, z
1., 1., 0.,
View gist:1202405
// Vertices drawn as GL_TRIANGLE_STRIP:
GLfloat d = 0.5f;
// We have 4 verts * 3 coords = 12 elements per slice
const GLfloat one_slice[12] = {
// x, y, z
-d, d, 0.,
d, d, 0.,
-d, -d, 0.,
d, -d, 0.,
};
View gist:1204675
{
float rotstep = ((M_PI / 2.) / 9.) / 2.;
GLKVector2 ndir = GLKVector2Normalize(direction);
_rx += ndir.y * rotstep;
if (_rx > M_PI_2)
_rx = M_PI_2;
if (_rx < -M_PI_2)
_rx = -M_PI_2;
_ry += ndir.x * rotstep;
@dennda
dennda / gist:1212172
Created Sep 12, 2011
setupSocket -- no callback
View gist:1212172
- (void) setupSocket {
struct sockaddr_in addr;
bzero(&addr, sizeof(addr));
addr.sin_len = sizeof(addr);
addr.sin_family = AF_INET;
// Ask kernel to randomly assign port
addr.sin_port = 0;
void* info = (__bridge void*) self;
@dennda
dennda / gist:1212363
Created Sep 12, 2011
This is how not to do callbacks / resolveWithTimeout
View gist:1212363
- (void)netServiceBrowser:(NSNetServiceBrowser *)netServiceBrowser
didFindService:(NSNetService *)netService
moreComing:(BOOL)moreServicesComing {
netService.delegate = self;
[netService scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
[netService resolveWithTimeout:3.0];
}
@dennda
dennda / gist:1212608
Created Sep 12, 2011
CFSocket: No accept callback? Here's the problem:
View gist:1212608
// Doesn't work:
readsock = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM,
IPPROTO_TCP, kCFSocketReadCallBack |
kCFSocketAcceptCallBack | kCFSocketDataCallBack |
kCFSocketConnectCallBack | kCFSocketWriteCallBack,
(CFSocketCallBack)&readSockCallBack, info);
// Works:
readsock = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_STREAM,
IPPROTO_TCP, kCFSocketAcceptCallBack,
View gist:1212964
// Send:
const uint8_t query = (uint8_t)USERNAME_QUERY;
const uint8_t length = (uint8_t)sizeof(query);
[stream write:&length maxLength:sizeof(uint8_t)];
[stream write:&query maxLength:length];
// Receive:
uint8_t length;
[inStream read:&length maxLength:sizeof(uint8_t)];