Skip to content

Instantly share code, notes, and snippets.

View DrPizza's full-sized avatar
🙄
they see me rollin'. they hatin'.

Peter Bright DrPizza

🙄
they see me rollin'. they hatin'.
View GitHub Profile
@DrPizza
DrPizza / gist:938097
Created April 23, 2011 01:20
libdispatch for Win32, oh yes.
#include "dispatch/dispatch.h"
dispatch_source_t source;
HANDLE evt;
struct OVERLAPPED_BUFFER {
OVERLAPPED ol;
size_t buffer_size;
void* buffer;
@DrPizza
DrPizza / gist:1039215
Created June 21, 2011 23:25
MetroTwit crash
Exception Info: Object reference not set to an instance of an object.
at MetroTwit.ViewModel.TweetListViewModel.<>c__DisplayClass1f.<StreamingUpdate>b__1b()
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
@DrPizza
DrPizza / gist:1039333
Created June 22, 2011 01:25
gcd for win32
#include "dispatch_test.h"
#include <dispatch.hpp>
#include <iostream>
LRESULT CALLBACK window_proc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
{
gcd::queue thread_q = gcd::queue::get_current_thread_queue();
switch(message) {
@DrPizza
DrPizza / gist:1045683
Created June 24, 2011 21:00
HWND to dispatch_queue_t mapping.
#include "dispatch_test.h"
#include <dispatch.hpp>
#include <iostream>
#include <map>
// TODO hunt down a concurrent map implementation
// TODO operator= for gcd::object
std::map<HWND, gcd::queue> window_queues;
// perform a simple mechanical transform from this:
{ req, res } = yield app.get(/^\/([0-9a-f]+)$/);
object_id = new bson.ObjectID(req.params[0]);
{ err, db } = yield db.open();
if(err) { return res.send(500); }
store = new mongo.GridStore(db, object_id, "r");
{ err, store } = yield store.open();
if(err || !store.length) { return res.send(404); }
{ err, buf } = yield store.readBuffer(store.length);
@DrPizza
DrPizza / gist:1080953
Created July 13, 2011 18:27
variadic templates.
#include <iostream>
#include <list>
#include <tuple>
#include <memory>
#include <initializer_list>
template<typename Function>
Function pack_for_each(Function f)
{
return f;
@DrPizza
DrPizza / gist:1125391
Created August 4, 2011 15:11
Revised test
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
@DrPizza
DrPizza / 0001-Make-MSVS-build.patch
Created August 7, 2011 05:13
0001-Make-MSVS-build.patch
From ca796c4128bd2133b4412a5ddfcfca28529c2e58 Mon Sep 17 00:00:00 2001
From: Peter Bright <drpizza@quiscalusmexicanus.org>
Date: Sun, 7 Aug 2011 06:11:21 +0100
Subject: [PATCH] Make MSVS build.
---
.gitignore | 15 ++++++
deps/http_parser/http_parser.gyp | 44 ++++++++++++++++-
deps/uv/build/all.gyp | 50 ++++++++++++++++----
deps/uv/deps/pthread-win32/build/all.gyp | 45 ++++++++++++++----
@DrPizza
DrPizza / 0001-Make-MSVS-build.patch
Created August 7, 2011 05:24
0001-Make-MSVS-build.patch
From 519641428c61be0adc1a817ec5df642d8483eaed Mon Sep 17 00:00:00 2001
From: Peter Bright <drpizza@quiscalusmexicanus.org>
Date: Sun, 7 Aug 2011 06:11:21 +0100
Subject: [PATCH] Make MSVS build.
MSVS settings don't actually need to be guarded by conditions. gyp will do the right thing.
---
.gitignore | 15 ++++++
deps/http_parser/http_parser.gyp | 35 +++++++++++++-
deps/uv/build/all.gyp | 42 +++++++++++++----
@DrPizza
DrPizza / all.gyp
Created August 8, 2011 18:30
VS2010 settings instead of VS2008 settings
{
'target_defaults': {
'default_configuration': 'Debug',
'configurations': {
# TODO: hoist these out and put them somewhere common, because
# RuntimeLibrary MUST MATCH across the entire project
'Debug': {
'defines': [ 'DEBUG', '_DEBUG' ],
'msbuild_settings': {
'ClCompile': {