Skip to content

Instantly share code, notes, and snippets.

00:37:06,120
When we're headed toward an outcome that's too horrible to face...
That's when we go looking for a second opinion.
And sometimes...
The answer we get just confirms our worst fears.
00:37:52,427 --> 00:37:53,378
Peace...
isn't a permanent state.
It exists in moments...
fleeting...
@rgl
rgl / chunk.c
Created January 31, 2010 14:15
HTTP chunked transfer in a libevent server
/*
This shows how to use HTTP chunked transfer in libevent. It starts an HTTP server on port 8080; when the client connects, it outputs an message every second. After all messages are outputted, the server closes the HTTP connection.
It has an unsolved crashing problem though... to see it crash, run the next commands in a shell.
See my ML post "after the http client abruptly closes socket libevent (2.0.3-alpha) http server crashes" at http://archives.seul.org/libevent/users/Jan-2010/msg00054.html
Compile with:
gcc -Wall -g -std=c99 -D_GNU_SOURCE -Iinclude -Llib -levent -o chunk chunk.c
Chinaski at the end of the Factotum movie:
If you are going to try,
go all the way.
Otherwise don't even start.
This could mean losing girlfriends,
wives, relatives, jobs.
$ time ab -n 100 -c 1 'http://localhost:9200/logs/_search?q=x'
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient).....done
Server Software:
Server Hostname: localhost
@rgl
rgl / ppa_stats.py
Created April 27, 2011 07:57
outputs the download count of a PPA
# this outputs the download count of a PPA
#
# See https://api.launchpad.net/+apidoc/devel.html#binary_package_publishing_history
# See https://help.launchpad.net/API/launchpadlib
from launchpadlib.launchpad import Launchpad
cachedir = '/home/rgl/.launchpadlib/cache/'
launchpad = Launchpad.login_anonymously('just testing', 'production', cachedir)
@rgl
rgl / gist:1070433
Created July 7, 2011 20:10
Recreate (drop and create) an SQL Server Database.
//
// Recreate (drop and create) an SQL Server Database.
//
// NB: This will place the database in single mode (also rolling back current transactions).
//
// usage: RecreateDatabase(@"Data Source=.\SQLServer; Initial catalog = ESB_Store_Development; Integrated Security=True;");
private static void RecreateSqlServerDatabase(string connectionString)
{
const string databaseNameRegexPattern = @"(;\s*Initial Catalog\s*=\s*)([^;]+)\s*";
@rgl
rgl / gist:1518960
Created December 25, 2011 08:56
Update a namecheap dynamic DNS address
@rgl
rgl / gist:2028339
Created March 13, 2012 11:45
Example on how to read application settings configuration
// NB you should probably use SixPack instead...
// On App.config:
/*
<configuration>
<configSections>
<section name="snmpPoller" type="Tracing.Service.Snmp.SnmpPollerSettings,Tracing.Service.Snmp"/>
</configSections>
<snmpPoller pollingInterval="4000" timeout="3000">
<variables>
@rgl
rgl / gist:2158698
Created March 22, 2012 14:41
Serialize xsd:anyType on a client proxy
/*
When you have a XML schema with a xsd:anyType element, eg:
<complexType name="Example">
<sequence>
<element name="DateTime" type="dateTime" minOccurs="1" maxOccurs="1" />
<element name="Value" type="string" minOccurs="1" maxOccurs="1" />
<element name="Details" type="anyType" minOccurs="0" maxOccurs="1" />
</sequence>
</complexType>