Skip to content

Instantly share code, notes, and snippets.

View bergie's full-sized avatar

Henri Bergius bergie

View GitHub Profile
import network, util
from util import exceptions
from gettext import lgettext as _
PROTOCOL_INFO = {
"name": "Qaiku",
"version": "1.0",
"config": [
"private:password",
<?php
if (count($argv) != 2)
{
die("Usage: php quick_init.php midgardconffile\n");
}
if (!extension_loaded('midgard2'))
{
die("Midgard2 is not installed in your PHP environment.\n");
}
@bergie
bergie / blog.markdown
Created January 15, 2011 11:08
Blog post in Midgard MVC

A blog in Midgard Create

This is an example of how to create a blog system powered by the Midgard Create web editing tool. This example follows the principles of literate programming, meaning that it is not only a human-readable document but can also be used to construct the full running blog system using the code examples inside this file.

As this blog system is an example application, we will call it net_example_blog. This will be used as a namespace in PHP classes and global variables.

Our blog post

To be able to store and display blog posts we have to first define a persistent storage for them. Midgard MVC itself is not in way tied to any storage solution, but in this case we will use the Midgard2 content repository for our data persistence needs. Midgard2 is an object-oriented content store that can be accessed from various programming languages including PHP, Python and Vala.

@bergie
bergie / evented.php
Created March 4, 2011 13:44
Event-driven programming example with PHP5 and Midgard2
<?php
// Open Midgard connection
$config = new midgard_config();
$config->read_file_at_path(ini_get('midgard.configuration_file'));
// Do stuff when we get a DB connection
midgard_connection::get_instance()->connect('connected', function($connection) {
echo "Connected, Midgard version " . mgd_version() . "\n";
});
if (typeof jQuery == 'undefined') {
var jQ = document.createElement('script');
jQ.type = 'text/javascript';
jQ.onload=loadDeps;
jQ.src = 'http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js';
document.body.appendChild(jQ);
} else {
loadDeps();
}
function loadDeps() {
@bergie
bergie / README.md
Created May 18, 2011 11:33
Falsy Values tutorials
@bergie
bergie / .gitignore
Created September 19, 2011 15:50
Node.js email handling examples
config.json
reading-image.png
@bergie
bergie / README.md
Created December 28, 2011 16:57
Midgard2 GIR examples

Some examples of Midgard2 GIR usage

@bergie
bergie / README.md
Created February 14, 2012 13:55
MQTT pub/sub example

This is a simple example of the MQTT protocol with Node.js. The client code has also been tested with a combination of C++ servers and clients.

@bergie
bergie / README.md
Created May 30, 2012 12:47
Backbone.js Collection View example

This is an example of using a Collection view with Backbone.