Skip to content

Instantly share code, notes, and snippets.

View jakedouglas's full-sized avatar

Jake Douglas jakedouglas

View GitHub Profile
#include "fifo.h"
#define ENSURE(foo) do { assert((foo) == 0); } while (0)
fifo_queue* queue_init()
{
fifo_queue *q = (fifo_queue*) malloc(sizeof(fifo_queue));
q->front = NULL;
q->back = NULL;
ENSURE(pthread_mutex_init(&q->mutex, NULL));
describe "EM hooks" do
it "encodes outbound objects as JSON" do
$test_obj = {
"JSON Test Pattern pass3"=>{
"The outermost value"=>"must be an object or array.",
"In this test"=>"It is an object."
}
}
#include "ruby.h"
typedef struct em_data {
char *data;
unsigned long len;
} em_data;
typedef struct em_hooks {
void *arg;
void (*em_recv_data)(em_data *unit, void *arg);
require 'eventmachine'
require 'testext'
module Server
def post_init
send_data "special test data"
end
end
hooks = EM::Hooks.new
diff --git a/kernel/common/dir.rb b/kernel/common/dir.rb
index 312cffa..cf4d185 100644
--- a/kernel/common/dir.rb
+++ b/kernel/common/dir.rb
@@ -373,19 +373,19 @@ class Dir
def self.chdir(path = ENV['HOME'])
if block_given?
original_path = self.getwd
- error = Platform::POSIX.chdir path
+ error = FFI::Platform::POSIX.chdir path
diff --git a/ext/cmain.cpp b/ext/cmain.cpp
index a75417c..2922338 100644
--- a/ext/cmain.cpp
+++ b/ext/cmain.cpp
@@ -783,12 +783,12 @@ extern "C" int evma_send_file_data_to_connection (const unsigned long binding, c
evma_start_proxy
*****************/
-extern "C" void evma_start_proxy (const unsigned long from, const unsigned long to)
+extern "C" void evma_start_proxy (const unsigned long from, const unsigned long to, const unsigned long bufsize)
@jakedouglas
jakedouglas / mach64.diff
Created September 21, 2009 02:13
make google perftools work on snow leopard
cd /path/to/google-perftools-1.4
patch -p0 < /path/to/mach64.diff
CFLAGS="-D_XOPEN_SOURCE" CXXFLAGS="-D_XOPEN_SOURCE" ./configure
make, make install, blah blah etc
@jakedouglas
jakedouglas / gist:135109
Created June 24, 2009 09:04
Simple UDP Growl packets in Lua
require "luarocks.require"
require "pack"
require "socket"
require "md5"
Growl = {version = 1, registration = 0, notification = 1}
function Growl.new(hostname, appname)
local mysock = assert(socket.udp())
#include <pthread.h>
#include <stdio.h>
#include <ruby.h>
#include "thrqueue.h"
static VALUE cThreadTest;
void *produce(struct Queue *q)
{
char *ptr = "foo";
diff --git a/ext/rubymain.cpp b/ext/rubymain.cpp
index 892f0fd..f0cf588 100644
--- a/ext/rubymain.cpp
+++ b/ext/rubymain.cpp
@@ -20,6 +20,7 @@ See the file COPYING for complete licensing information.
#include "project.h"
#include "eventmachine.h"
#include <ruby.h>
+#include <st.h>