Skip to content

Instantly share code, notes, and snippets.

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} ."
#!/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 *
- (void) setupSockets {
void* info = (__bridge void*) self;
readsock = CFSocketCreate(kCFAllocatorDefault, PF_INET, SOCK_DGRAM,
IPPROTO_UDP, kCFSocketReadCallBack |
kCFSocketAcceptCallBack | kCFSocketDataCallBack |
kCFSocketConnectCallBack | kCFSocketWriteCallBack,
(CFSocketCallBack)readSockCallBack, info);
....
}
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.,
// 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.,
};
{
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 September 12, 2011 19:36
setupSocket -- no callback
- (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 September 12, 2011 20:49
This is how not to do callbacks / resolveWithTimeout
- (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 September 12, 2011 22:10
CFSocket: No accept callback? Here's the problem:
// 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,
@dennda
dennda / gist:1212964
Created September 13, 2011 01:52
Send & Receive
// 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)];