Django Signals Example

signals

Have you read the Django Signals Documentation and wondered, “Okay, how the heck do you actually use it? How about an example?” If so, then you’ve come to the right place.

Will demo by example adding signals for pre_save, pre_delete to raise an exception if a READ_ONLY_FILE exists to prevent the DB from changing. Then, add signals for post_save and post_delete to print the change to stdout. Using print as an example, a more useful thing would be to write it to syslog or something – say you want to log every DB change that occurs.

Read moreDjango Signals Example

Lazy Social Buttons

Lazy Social Buttons

Want social buttons on your wordpress blog pages, but you don’t want to pay the performance penalty? Try Lazy Social Buttons by Go Daddy.

The WordPress Plugin is a wrapper for the Go Daddy open source lazy-social-buttons posted on github written by LindsayD. She’s the real mastermind behind this. I merely evangelized the concept like mad, then put a WordPress wrapper on the outcome.

Read moreLazy Social Buttons

Go Daddy API, Example use

Very recently, Go Daddy released it’s public API that can be used with Go Daddy Cloud Servers and Easy Database. Since I’m a Go Daddy Cloud Servers customer (and employee of Go Daddy), I wanted to provide you with an example use of the API.

I had an extra server that I wanted to delete. Of course, I could do this with the GUI, but for practice, I decided to delete it with a script.

The first thing I did was grabbed a copy of the Go Daddy API for PHP, which can be found here:
https://github.com/godaddy/gdapi-php

and gave the documentation a once over:
http://docs.cloud.secureserver.net/

I then went to the Go Daddy Cloud Servers GUI and clicked the API tab, accepted the TOS, and generated an API key. It was easy, one click and my access key and secret key were provided.

I then created a file called csremove.php:

Read moreGo Daddy API, Example use

Making bp-events work on BuddyPress 1.2 (with invites working)

There is a lot of chatter about wanting the plugin creator to update bp-events to work with Buddypress version 1.2, and so far it hasn’t happened, however, this guy has ported it for us so kindly:

http://codewarrior.getpaidfrom.us/2010/04/21/buddypress-event-plugin-for-1-2/

Read moreMaking bp-events work on BuddyPress 1.2 (with invites working)

Hack to make vipers-video-quicktags detect iPad and use HTML5 Video Tag

I use this WordPress plugin, vipers-video-quicktag, in a couple sites I maintain. I use it to display FLV video. I’ve found if I create .mp4 videos with the H.262 video and AAC audio codecs, it’ll play in the Flash player, as well as on iPhone, iPad and iPod. This is neat, a single video format … Read moreHack to make vipers-video-quicktags detect iPad and use HTML5 Video Tag

Putting a Facebook share link on your site

Putting this up as an example of how to do a share link. It’s a share link to http://goshinkarate.com/intro_offer.html (my kids take Karate here – Great program!)   Share   The code for this is:   You can put this code on your site and let your visitors share the Goshin Karate introductory special with … Read morePutting a Facebook share link on your site

BP Events bp-events invites broken, workaround

bp-events version 1.1 on top of buddypress 1.1.3 isn’t working for invites, it’s broken. After hours and hours of combing the web looking for a solution, I couldn’t find one. I figured out a workaround.

There were several other places online that I found other complain about this same problem. As far as I can tell, nobody has published any solution or workaround. Until now. I have a workaround – more like a hack, but it works!

I don’t know the WordPress/BuddyPress framework, but I’m pretty skilled at PHP, and can debug by following the HTTP request, and walk through the codebase. I used tcpflow to watch the HTTP requests and responses, and walked the codebase by dropping print lines in appropriate places to see how the request traversed the code.

Here’s what I found out. When bp-events gets to the “Send Invites” section, when you check a checkbox of a friend, it invokes an AJAX call, via JavaScript, to wp-load.php. Well, what it sends to the server is action=groups_invite_user, friend_id=. Everything else is hogwash. There is nothing in the request to tell you what event it’s for!

Ok, so the reason for this is that bp-events uses the same api as bp groups. It borrows from bp groups to draw your “Select Friends” widget. I have not found the real root cause. What it’s supposed to do is send an action=events_invite_user and should also send the event_id, I speculate. I haven’t been able to figure out how to craft an HTTP request to wp-load.php that will perform the intended behavior. I do, however, have a workaround that fixes the problem. Keep reading if you want a workaround hack that fixes this problem.

Read moreBP Events bp-events invites broken, workaround