Archive for March, 2009

GitHub PHP WebHook

So I just wrote my first webhook. Pretty exciting.

Here it is in all its glory. Post-commit from GitHub repo.

<?php
// Decode json payload
$payload = $_POST['payload'];
$data = json_decode(stripslashes($payload));
 
// read commit messages and forward '# ...' messages to twitter clone
if(is_object($data) && is_array($data->commits)) {
    foreach($data->commits as $commit) {
        if($commit->author->name == 'KevBurnsJr' 
        && substr($commit->message, 0, 1) == '#') {
 
            $url = 'http://user:pass@tools.companyname.com/twitter_clone.php';
 
            // form fields
            $data = array(
                'headline' => substr($commit->message, 2),
                'hightlight' => 0,
                'workgroup' => 5,
                'submit' => 'Save',
                'userid' => 4
            );
 
            do_post_request($url, http_build_query($data));
        }
    } 
} else {
    die('no data');
}
 
// This function makes the requests.  
// http://netevil.org/blog/2006/nov/http-post-from-php-without-curl
function do_post_request($url, $data, $optional_headers = null) {
    $params = array('http' => array(
        'method' => 'POST',
        'content' => $data
    ));
    if ($optional_headers !== null) {
        $params['http']['header'] = $optional_headers;
    }
    $ctx = stream_context_create($params);
    $fp = @fopen($url, 'rb', false, $ctx);
    $response = @stream_get_contents($fp);
    return $response;
}

Illegal Links

Link to the wrong website in Australia and you could be fined $11,000 per day. http://is.gd/nDGe

We bitch about our antiquated bureaucracy here in the states, but hey, at least we’ve got free speech figured out.

Another weekend of hacking

This time I got some company from folks like @alienvenom at the Pi Day SuperHappyDevHouse

http://superhappydevhouse.org/

More hacking on Orbited’s IRC Demo
http://irc.hackyhack.net/

Cloned my hacked client to connect to SHDH on freenode
http://shdh.cloudbots.net/

Did some work on making my simple auth app for Recess! a little more generic in prep for modules.  Should have it up live on CloudBots soon.
http://cloudbots.net/

Doot dee doo, i guess that’s it.  Feels funny working on all this peripheral stuff without seeing how it’s all going to tie together.

Oh, I heard Mibbit may soon become the default IRC protocol web handler for irc:// and ircs:// in FireFox.  That’s pretty cool.  I wasn’t involved in the project, but I have been following it.  Axod’s obviously put a lot of work into it.  Interesting to see all the pieces required to bring a service like that together.  Congrats.

Abandoned Source

What happens when that open source library you’ve come to depend on loses momentum?  When the revisions stop being published and the lead developer goes dark?

You can either throw in the shovel and learn to use another library that doesn’t do quite what you want, quite as well, or pick up where the trail ends and try your hand at creating high quality software.

Unfortunately for us all, the former is often the path most followed.

Remember that open source software is not the result of free labor, it is the result of volunteer labor.

Be thankful that you don’t have to reverse engineer the obfuscated libraries.

WYMeditor now faces a similar fate.

A weekend of hacking

Eggdrop bot : installed and configured.

PHP Eggdrop log parser : uploaded and heavily modified.
http://kevburnsjr.com/recesslogs/ 

Inspircd IRC server configured and running.

Orbited installed and configured to play nice with Apache.

Orbited’s demo JS IRC client installed and slightly modified.
http://irc.hackyhack.net/

I’ve been wanting to do something like this ever since I saw Axod’s Mibbit.

Talkie.me gave me a good deal of inspiration as well.

Next up : keep hacking the demo client and tie Inspircd to MySQL for some serious fucked up flipper baby action.

Re: Naming Conventions for Views and Helpers in Recess PHP Framework

This post is a response to Joshua Paine’s blog entry Naming Conventions for Views and Helpers in Recess PHP Framework

1) CamelCase : Agree.

2) Capitalization of View Helpers : LoL @ Aladdin reference.  Agree.

3) Changing view to template :

I agree that the name view could lead to confusion.  I also agree that the word template is longish.  However, I think page would not make a good name for the class.  Using the word page implies a context, that the template being rendered is a part of a page.  It might be a partial being returned in an AJAH request without the body and html elements, or might not contain HTML at all.

One of the most used methods in the simple framework I whipped up is Template::render($tpl_name, $data).

It seems to me that all methods contained within the view page class are specific to the rendering of templates.

So… how about the class name tpl ?

tpl::start('foo/bar');
    tpl::block('head');
        <script src="foo.js"></script>
    tpl::blockEnd();
tpl::end();

 
Additionally, I get the feeling there may come the need for a layout view helper.  Not sure how it might fit in just yet.

4) Paired function names like block and endBlock : see above, recommend block(’params’), blockEnd() //no params