Skip to content

Instantly share code, notes, and snippets.

<?php
class pubsubhubbub{
var $callback_url; //the url we need to post the updates to
var $title; //the title of the url
var $created_time; //time is was created
var $subscription_state;//the state of the subscription (pending for confirmation/ verified)
function __construct() //we accept the above parameters and save it in the db.
<?php
//resides in the webapp folder.
require_once ('config.webapp.inc.php');
ini_set("include_path", ini_get("include_path").PATH_SEPARATOR.$INCLUDE_PATH);
require_once ("init.php");
$THINKTANK_CFG['site_url'] = 'http://localhost'; //this will go in config.inc.php
$db = new Database($THINKTANK_CFG);
<?php
//initialized in config.inc.php
$THINKTANK_CFG['site_url'] = "";
require_once ("common/init.php");
$db = new Database($THINKTANK_CFG);
$conn = $db->getConnection();
$cfg = new Config();
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:georss="http://www.georss.org/georss">
<channel>
<title>Public Timeline</title>
<link>{$cfg->site_url}{$cfg->site_root_path}public.php?v={$option}</link>
<atom:link type="application/rss+xml" href="{$cfg->site_url}{$cfg->site_root_path}rss.php?v={$option}" rel="self"/>
<description>The latest from ThinkTank</description>
<language>en</language>
{foreach item=post from=$posts}
<item>
local st = require "util.stanza";
local reply = st.stanza("message");
reply:tag("body"):text("Enter the valid keys"):up()
:tag("x", {xmlns="jabber:x:oob"}):tag("url"):text("some_url"):up():up()
:tag("captcha", {xmlns="urn:xmpp:captcha"}):up();
print (reply);
-- <message><body>Enter the valid keys</body><x xmlns='jabber:x:oob'>
@tsudot
tsudot / mod_jinglerelaynodes.lua
Created August 6, 2011 19:47
Jingle Relay Nodes implementation in Prosody.
local st = require "util.stanza";
local host = module:get_host();
local stun_ip = module:get_option('stun_ip');
local stun_port = module:get_option_number('stun_port');
local uuid = require "util.uuid";
module:add_feature('http://jabber.org/protocol/jinglenodes');
module:hook('iq-get/host/http://jabber.org/protocol/jinglenodes', function(event)
local session, stanza = event.origin, event.stanza;
@tsudot
tsudot / mod_jinglechannel.lua
Created August 6, 2011 19:55
Implementaion of Jingle Channel Service in Prosody
--Jingle Channel Implementation
local _G = _G;
local prosody = _G.prosody;
local hosts = prosody.hosts;
local connlistener_register = require "net.connlisteners".register;
local localport = module:get_option_number("jingle_channel_read_port") or 35800;
local remoteport = module:get_option_number("jingle_channel_write_port") or 35802;
-- STUN server
local _G = _G;
local prosody = _G.prosody;
local hosts = prosody.hosts;
local connlisteners_register = require "net.connlisteners".register;
local stun_listener = { default_port = 3478; default_mode = "*a"; default_interface = "*" };
@tsudot
tsudot / dynamic.py
Created June 1, 2012 05:07
loading modules dynamically
def load(self):
self.plugins = ['monit', 'opensips', 'sshd']
self.fetch_config()
plugins = {}
for plugin in self.plugins:
# get_class_name returns the class nume for that plugin,
# for a new plugin we need to have a standard class name
# for example the module name capitalized with the first word
plugins[plugin] = getattr(__import__(plugin), get_class_name(plugin))
@tsudot
tsudot / record_plivo.php
Created July 4, 2012 12:50
Record XML Plivo
<?php
require_once "plivo.php";
$r = new Response();
$speak_body = "Please leave a message after the beep. Press the star key when done.";
$r->addSpeak($speak_body);