My Blog

TweetBytes is now @Tweet

@tweetbytes is now @tweet, thanks to txtWeb’s recognition of the popularity of the app amongst txtWeb users.

Now that it got a snappier keyword, what does it mean for the current users? Simply put, it just got better, and easier to access. Existing users of @tweetbytes needn’t do anything to access the application through the new keyword. It is a seamless migration and existing users can start tweeting through @tweet right away.

While the keyword has changed, I’ve however planned to retain the application name. Also, the application will be accessible through both @tweetbytes and @tweet, until a while at least.

Tweet away. :)

Earlier Post: Launching Tweebytes

Comment

55444 Search for Chrome

Got a week’s break, and at least one night had to be some night of hacking. I was going through the 55444 Developers group on Facebook and saw that a Chrome extension emulator could help some developers in testing of applications. So I gave myself the job of developing my first Chrome extension plugin.

These extensions, of course, cannot run any sort of server side scripts, and need to be built entirely upon JavaScript. With this plugin using a third-party server application, cross-domain AJAX requests had to be made. Testing on the browser first never seemed to be working, and I found out from the console logs that Chrome blocks all cross-domain AJAX requests for security reasons. Took me a while to realize that I unless I package it into a plugin with appropriate domain permissions, testing would never work.

After that and creating icons, and arranging some CSS, it looked good to be published. So I logged into the Chrome Store Developer Dashboard and went through the whole process and at the end of it realized that there was $5 registration fee for publishing the app! Ah, why. I just left it at that. Not like I plan to develop any more Chrome extensions.

This, however, won’t go of waste. You can install the search plugin by downloading the packaged .crx file from this link here. Then go to chrome://extensions on your browser, and drag and drop the downloaded crx file into the Chrome browser.

I’ve open-sourced it on GitHub with a GPLv2 License. I’m no expert with these Open Source licenses, but I care about sharing improvements. :D

Comment

My First WordPress Plugin

With great delight, I have contributed my first official piece of code to the WordPress repository!

http://wordpress.org/extend/plugins/stack-overflow-activity-feed-widget/

I was always eager to be a part of the WordPress community, for WordPress is something that I have heavily used for almost a couple of years now, and is something that I am very passionate about. A lot of websites, experiments, hacks, and a lot of fun. It has been a training ground for me to learn PHP, and web development.

And finally, there is something official, in the form of a simple plugin, but this, I believe is only a start to what I think I could be doing for the community.

Comment

Exploits of a Mom

Found this on xkcd. :D. Definitely worth sharing.

Exploits of a Mom

Comment

Google and Special Characters

It must not be one programmer’s frustration that Google does not consider special characters in its search field to return results. Now if I can’t search for resources on what is the difference between @ and \@ in Perl when assigning arrays, where else am I to head to?

“What is the difference between an ocean and a sea?” That is absolutely what I wanted.

Google Search Result

Edit: Thanks to Carl’s comment. You can check out the results for the same from SymbolHound here.

Comment

Amazon

I write now, at the milestone of my first code being pushed into the Amazon production servers, reflecting across a million Kindle devices. Just a few lines of code. But such an amazing feeling.

Working for a company that I believe has one of the best build systems ever, you wouldn’t imagine the pace at which development happens, and how soon you actually impact customers, and the company.

I really look forward to do the great work that people around me do.

Comment

A Good Year

It was. :). I’ll remember you, 2012.

Comment

Fixing The Twitter Widget

Twitter has been giving too much problems to a lot of people lately, ever since they updated their API to v1.1 making their Developer Rules of the Road more stringent. While it did affect developers in specific, with quite a number of them having to update their existing applications to stay consistent with the API guidelines, a lot of innocent bloggers were also affected by the new API, to suddenly see their Twitter widgets stop working.

Well I have a Twitter widget on my site too, and it for months has been just dead. But not anymore. There is a simple fix which if you haven’t done yet will bring it back alive.

Regardless of what platform you were on, you basically need to find this piece of code in the widget:

<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/'.$account.'.json?callback=twitterCallback2&amp;count='.$show.'"></script>

And replace it with this:

<script type="text/javascript" src="http://api.twitter.com/1/statuses/user_timeline/'.$account.'.json?callback=twitterCallback2&amp;count='.$show.'"></script>

And you’re done!

Comment

Open Sourcing WordPress on SMS

How would it be if you could blog through your phone? Even without the Internet?

Well now you can, using #WordPress. Honestly, the application should be in its beta stage, but I have versioned it as 1.0. :D. And yes, it is open sourced here. Finally some piece of code that I decided to open source without worrying much over how people would evaluate me after reading through it.

You’re welcome to get in touch with me if you would like to suggest any changes in its features. Or the code. :)

Comment

Yet Another WordPress Hack

I do not very well remember how much I’ve screwed around with WordPress and its plugins, but here is one of my latest mods to an existing plugin that I believe will be very useful for users wanting to import all photos from their photo albums of a particular Facebook page. I had been searching around for plugins, and could never find one that could actually do the job. Either if a plugin could display all photos from all albums it didn’t have the feature to read from a Facebook page and was rather limited to just Facebook users, like the Fotobook plugin. Or if it could read from pages, then I had to specify each and every album ID separately in the shortcode, and add as many shortcodes as there are albums in that Facebook page. And moreover, updates in the gallery page to include the new shortcodes for newly added albums on Facebook had to be done manually. It fit in only if I wanted to display selected albums. But then I had to just display all of them, and there were more than ten albums that could possibly keep increasing every month or sooner.

And fetching the album IDs of each of those ten albums was trouble again. Say you open an album and read the URL on the address bar. You would see something like this: https://www.facebook.com/media/set/?set=a.10151028573106217.485132.286244581216&type=3. The number in between the first dot after ‘a’ and in between second dot becomes your album ID. And would I like to manually read each of those album IDs, and that too every time a new album is added? And then manually add it to the page in the website? No!

So I found this plugin Facebook Page Photo Gallery, but which like I said could only display based on the album ID in specific, and it required me to add each album ID manually as a shortcode:

[fbphotos id=albumid]

I liked the overall feel of the plugin, and the thumbnail style and the jQuery effects that the developer had used in his plugin. And then it was time for me to start digging into the code. I narrowed down to this function, where in he generates a string containing the HTML to be printed, which again is generated by calling the fppg_get_photos() function by passing the album ID. Here is the original piece of code from facebook-page-photo-gallery.php, starting from line 34.

/*Function to hook to an embedding shortcode 
 * @param $album array passed through shortcode
 * 
 */

function fppg_embed_photos($album) {

static $count=0;
$count++;
extract( shortcode_atts( array(
		'id' => '',
		'limit' => 300,
                'rand'=>false
	), $album ) );
$div='
'.fppg_get_photos($id,$limit,$rand).'
'; return($div); }

Great. What I needed to change was to loop over the piece of code generating the HTML for each and every album rather than just the one album. So here is what I did. This was the page of my interest: https://www.facebook.com/pages/Sunshine-Foundation/286244581216, and its ID was 286244581216. And then I went to https://graph.facebook.com/286244581216/albums to get the details of all albums of that particular page in JSON format.

Just a small note here, if suppose a page has a registered username and does not have its ID in the page URL, say like https://www.facebook.com/CocaCola, then go to https://graph.facebook.com/CocaCola to retrieve its ID as one of the JSON objects.

Now that I had details of all the albums of a particular page in JSON format, the next thing that I needed to do was parse the JSON and retrieve the IDs of all the albums from the JSON, and run these album IDs in a loop through the previous code. The modified code is here, with the function fppg_embed_photos() replaced by mine.

function fppg_embed_photos($album) {

static $count=0;
$count++;
extract( shortcode_atts( array(
		'id' => '',
		'limit' => 300,
                'rand'=>false
	), $album ) );

/* Fetching the JSON Data from the graph.facebook.com/pageid/albums URL */
$fbAlbums=file_get_contents('http://graph.facebook.com/'.$id.'/albums');

/* Decoding the JSON Data and storing it in $fbData */
$fbData=json_decode($fbAlbums,true);

$div=" ";

/* Looping each $fbData['data'] */
foreach ($fbData['data'] as $fbPhotoAlbum)
{
/* Fetching 'id' of each album by $fbPhotoAlbum['id'], and passing that to fppg_get_photos(), and concatenating each of the generated HTML with itself and assigning it back to $div */
/* Also printing the album name by fetching it from the JSON data using $fbPhotoAlbum['name'] - Optional */
/* You can replace   as however you would like to, like for example 
  • for each album name to be in a bulleted list */ $div=$div.''.$fbPhotoAlbum['name'].'
    '.'
    '.fppg_get_photos($fbPhotoAlbum['id'],$limit,$rand).'
    '; /* Removing album names of any album with the name 'Untitled Album' - Optional */ $div=str_replace('Untitled Album;','',$div); } return($div); }
  • There we go, and this is how it looks on site, here. You can find the edited source code for download here. Download the original plugin, and replace the facebook-page-photo-gallery.php with the new downloaded file after extraction. And then now, your shortcode will have to be called only once, with the page ID of the Facebook page, rather than with some album ID.

    [fbphotos id=pageid]

    That does it! :). And don’t mind coming back to your photo gallery page ever again to update or add anything. The albums will automatically update as they are fetched from the Facebook page. Just keep those albums and photos rolling on in Facebook, and see them spring up there.

    Comment
    Copyright © Bits and Bytes | Arjun Abhynav. Powered by WordPress.