Skip to content

Instantly share code, notes, and snippets.

@GaretJax
GaretJax / tamqclientfactory.py
Created August 20, 2009 18:08
A transport class and a factory for thrift clients
from tamqtransport import TAMQTransport
from thrift.protocol import TBinaryProtocol
class TAMQBinaryProtocol(TBinaryProtocol):
def readMessageEnd(self):
self.trans.notifyMessageEnd()
class TAMQClientFactory(object):
def __init__(self, channel, services_exchange='services',
responses_exchange='responses', protocol_class=None):
proc = Processor(CalculatorHandler())
application = service.Application("My AMQP demo")
serviceCollection = service.IServiceCollection(application)
service = internet.TCPClient(host, port, AMQPClientFactory(proc))
service.setServiceParent(serviceCollection)
rpcservice = internet.TCPServer(9090, ThriftServerFactory(proc, TBinaryProtocol.TBinaryProtocolFactory()))
int main (int argc, const char * argv[]) {
char m = 'a';
char * m2 = &m; // Assign address of m to m2
char * m3 = "a"; // Create a new string and assign its starting address to m3
*m2 = 'x'; // OK
*m3 = 'x'; // EXEC_BAD_ACCESS
return 0;
private process TicketShop {
// Wait to receive the array containing the references to all cars
receive this.cars(this.cars);
// Light sanity check to ensure that we have a valid cars array
// NOTE: We don't test for null values here and the whole array is
// passed by reference (are we sure? How behaves JR when passing
// values around using messages between multiple virtual machines?)
assert this.cars != null && this.cars.length > 0;
<?php
// Loads the class
require 'path/to/Browscap.php';
// Creates a new Browscap object (loads or creates the cache)
$bc = new Browscap('path/to/the/cache/dir');
// Gets information about the current browser's user agent
$current_browser = $bc->getBrowser();
class FileSender(object):
...
def send_data(self):
chunk_size = 128 * 1024
data = self.source.read(chunk_size)
while data:
2010-07-26 18:37:46+0200 [ThriftAMQClient,client] RECEIVED 1280162266 (0 seconds late)
2010-07-26 18:37:49+0200 [ThriftAMQClient,client] RECEIVED 1280162269 (0 seconds late)
2010-07-26 18:37:52+0200 [ThriftAMQClient,client] RECEIVED 1280162272 (0 seconds late)
2010-07-26 18:37:55+0200 [ThriftAMQClient,client] RECEIVED 1280162275 (0 seconds late)
2010-07-26 18:37:58+0200 [ThriftAMQClient,client] RECEIVED 1280162278 (0 seconds late)
2010-07-26 18:38:07+0200 [-] Module smac.Recorder.FilesystemRecorder.1 gone
2010-07-26 18:38:10+0200 [ThriftAMQClient,client] RECEIVED 1280162281 (9 seconds late)
2010-07-26 18:38:10+0200 [ThriftAMQClient,client] Module smac.Recorder.FilesystemRecorder.1 announced
^C2010-07-26 18:38:16+0200 [-] Received SIGINT, shutting down.
<!DOCTYPE html>
<html dir="ltr" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>jQuery Card reader</title>
<!-- Include the scripts -->
<script type="text/javascript" charset="utf-8" src="scripts/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="scripts/CardReader.js"></script>
[CENTER]<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%"> <tbody> <tr> <td>*[IMG]http://www.tikonline.de/stargalerien/bilder/hTwilight_New_Moon.jpg[/IMG][IMG]http://upload.wikimedia.org/wikipedia/en/6/6a/Newmoonposter.JPG[/IMG] </td> <td>[B]Titolo Italiano: [/B]New Moon
[B]Titolo Originale: [/B]New Moon
[B]Genere: [/B]fantastico, horror, romantico
[B]Durata: [/B]130'
[B]AnimeDB Progetto: [/B][URL="http://Nessuno"]Nessuno[/URL]
[B]Gruppo FanSub: [/B]Nessuno
[B]Upper: [/B][coloruguale#0080FF][B]HusheR[/B][/color]
</td></tr></tbody></table>[/CENTER]
[contenuto=http://it.wikipedia.org/wiki/New_Moon_%28film_2009%29]Bella Swan partecipa ad una festa per il suo diciottesimo compleanno organizzata in casa della famiglia di Edward Cullen, il vampiro eternamente diciassettenne di cui si è innamorata. Aprendo un regalo si ferisce accidentalmente con la carta del pacco scatenando la reazione violenta di uno dei membri della famiglia Cullen, Jasper che essendo l'ultimo arrivato nel clan non ri
#include "sync.h"
void monitor_acquire(Monitor * monitor) {
P(monitor->mutex);
}
void monitor_release(Monitor * monitor) {
if (sem_getvalue(monitor->next) > 0) {
V(monitor->next);