Skip to content

Instantly share code, notes, and snippets.

View pcapriotti's full-sized avatar

Paolo Capriotti pcapriotti

View GitHub Profile
@pcapriotti
pcapriotti / http.hs
Created February 12, 2012 15:12
Sketch of http server implementation based on pipes
import Control.Monad
import Control.Pipe
import Control.Pipe.ChunkPipe
import Control.Pipe.Monoidal
import Data.ByteString (ByteString, empty)
import Data.List
import Data.Void
import Network.Socket
type Input = Either RequestH ByteString
@pcapriotti
pcapriotti / gist:1761136
Created February 7, 2012 18:30
Composition of free monads
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-}
import Control.Monad
import Control.Monad.Free
class (Functor f, Functor g, Functor h) => Compose f g h | f g -> h where
compose :: f x -> g y -> Free h (Free f x, Free g y)
compose f g = return (liftF f, liftF g)
composeF :: Compose f g h => Free f x -> Free g x -> Free h x
@pcapriotti
pcapriotti / reactor.py
Created July 16, 2011 08:54
Reactor Framework
"""The reactor framework.
This module introduces the *reactor framework*, a collection of utilities to be
used in conjunction with the greelet library to solve the problem of inversion
of control in event-driven code.
Traditionally, writing event-driven code typically consists of "connecting"
signals to handlers (i.e. callbacks), which are to be invoked by the framework
in use when a certain "event" occurs.
From ba220db019793794ed068a4c1441eecee330ea65 Mon Sep 17 00:00:00 2001
From: Paolo Capriotti <paolo.capriotti@collabora.co.uk>
Date: Wed, 27 Oct 2010 18:32:26 +0100
Subject: [PATCH] Simplify function regexp and fix bug for pointer and reference return types.
---
vim-protodef/pullproto.pl | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/vim-protodef/pullproto.pl b/vim-protodef/pullproto.pl
def on(sig, types = nil, &blk)
sig = Signal.create(sig, types)
candidates = if is_a? Qt::Object
signal_map[sig.symbol]
end
if candidates
if types
# find candidate with the correct argument types
candidates = candidates.find_all{|s| s[1] == types }
end
Index: ruby/qtruby/src/handlers.cpp
===================================================================
--- ruby/qtruby/src/handlers.cpp (revision 1148646)
+++ ruby/qtruby/src/handlers.cpp (working copy)
@@ -333,6 +333,14 @@
if (item->parentItem() == 0) {
mark_qgraphicsitem_children(item);
}
+ if (QGraphicsEffect* effect = item->graphicsEffect()) {
+ obj = getPointerObject(effect);
Index: ruby/qtruby/src/Qt.cpp
===================================================================
--- ruby/qtruby/src/Qt.cpp (revision 1148646)
+++ ruby/qtruby/src/Qt.cpp (working copy)
@@ -99,7 +99,7 @@
int do_debug = qtdb_none;
#endif
-typedef QHash<void *, VALUE *> PointerMap;
+typedef QHash<void *, SmokeValue> PointerMap;
Index: ruby/qtruby/src/handlers.cpp
===================================================================
--- ruby/qtruby/src/handlers.cpp (revision 1148646)
+++ ruby/qtruby/src/handlers.cpp (working copy)
@@ -2403,6 +2403,7 @@
{ "int*", marshall_it<int *> },
{ "int&", marshall_it<int *> },
{ "KIO::filesize_t", marshall_it<long long> },
+ { "long long", marshall_it<long long> },
{ "long long int", marshall_it<long long> },
#0 0x0821ef47 in rubinius::ObjectHeader::zone (this=0xb79cf468) at vm/oop.hpp:290
#1 0x083211bd in rubinius::ObjectHeader::young_object_p (this=0xb79cf468) at vm/oop.hpp:377
#2 0x083bef53 in rubinius::BakerGC::collect (this=0x8dbe2f8, data=..., stats=0xbfff42b8)
at vm/gc/baker.cpp:178
#3 0x0822af6f in rubinius::ObjectMemory::collect_young (this=0x8dbe150, data=..., stats=0xbfff42b8)
at vm/objectmemory.cpp:177
#4 0x08326f9d in rubinius::VM::collect_maybe (this=0x8dbdfe0, call_frame=0xbfff435c) at vm/vm.cpp:356
#5 0x0841f4d8 in rbx_prologue_check (state=0x8dbdfe0, call_frame=0xbfff435c) at vm/llvm/jit_util.cpp:675
#6 0xb63fed84 in ?? ()
#7 0x0827152a in rubinius::Dispatch::send (this=0xbfff4408, state=0x8dbdfe0, call_frame=0xbfff46f4,
From 6efed7c47bb0f0b2af835061a3993c705ba058b7 Mon Sep 17 00:00:00 2001
From: Paolo Capriotti <p.capriotti@gmail.com>
Date: Sat, 10 Jul 2010 15:50:21 +0100
Subject: [PATCH] Initial port to rubinius.
---
src/CMakeLists.txt | 3 +++
src/Qt.cpp | 6 +++++-
src/qtruby.cpp | 3 +++
3 files changed, 11 insertions(+), 1 deletions(-)