Categories
Reviews

Best Regular Expression Tools for Programmers

If you are a programmer, then you must have encountered regular expressions sometime back in your carrier. If you are good at regular expressions, then hats off to you. Otherwise there are some tools which can make your life easy.

There is one online and one offline tool  that I often use for regular expression purpose which I like to share with you today.

1. Regular Expression Online Tool

This is my favorite and the best for PHP, Perl & JavaScript programmer. Not only its AJAX interface allow to you to try different sets of regular expression but also generate code based on programming language you select.

ADVERTISEMENT

For PHP, it supports both PCRE (Perl Compatible Regular Expression) and POSIX library. There is no support for other languages but I that only means you may not be able to generate code for those. You can still use this to verify your regular expressions.

Link: Regular Expression Online Tool by Lars Olav Torvik

2. Regular Expression Desktop Tool

This is good for programmer who prefer desktop tools. This small Adobe Air application allow you to test different types of regular expression with help tips at each point.

ADVERTISEMENT

If you are new to regular expression,  then this is best for you as it not only help you write correct regular expressions, but also gives you many details about them at each stage.

As this is Adobe Air app, this can be used on Windows, Mac & Linux. This tool also have an online version. You can try it out here.

Link: RegExr Desktop by gSkinner

In my workflow, I often practice start with desktop tool first. I try all possibilities until I get intended results. When I am satisfied with results, I open online tool, put my regular expression there and grab codes which I can directly paste in my programs.

I code mostly in PHP & JavaScript so these tools are sufficient for me. If you have any other favorite, please share with us.

Related:  Online Source Code beautifier (formatter) for C, Java, Javascript, JSON, PHP, Perl, SQL & other

Categories
Tutorial

Moving a WordPress blog from a subdirectory to subdomain preserving permalinks

Many bloggers like to keep their blog in either subdirectory (ex: something.com/blog) or subdomain (ex: blog.something.com). Generally personal blogs are hosted under subdirectories and blog dedicated to services hosted under subdomains.

Anyway, if one want to move his wordpress blog from a subdirectory to a subdomain or vice-versa, it is possible to do so without loosing permalinks and traffic from search engines.

Listed below are steps with case of moving our orkutfeeds service blog from http://www.orkutfeeds.com/blog to http://blog.orkutfeeds.com/. You should change things accordingly as per your configuration.

[Note: Please configure subdomain first, it you are moving to a subdomain. Please create a subdirectory first if you are moving to a subdirectory.]

ADVERTISEMENT

1. Configuring wordpress

Login to your wordpress dashboard and go to General settings tab. You will see WordPress address(URL) & Blog address(URL) settings. Change them to target URL.

In our case it was http://www.orkutfeeds.com/blog which I changed to http://blog.orkutfeeds.com/.

ADVERTISEMENT

Change both URL settings carefully as one character mistake may result in disaster. Don’t worry nothing will be lost, only you will need to find a wordpress expert to fix it.

So after you are sure, press Save Changes button. You will see something like URL not found error but don’t get panic. It is expected as we haven’t moved/copied our blog files to subdomain yet. If your blog is high traffic blog then you may copy your blog files first as explained in next step.

2. Moving/Copying Blog Files

Moving files:

Now this step is trickiest one and your smartness will decide how long your blog will remain down.

ADVERTISEMENT

If you have shell access to your webserver and its Linux/Unix based server then you can use mv command to move all blog files at once. It took less than 1 second in orkutfeeds case!

ex: $mv path_to_domain_dir/blog/* path_to_subdomain_dir/

Note that, here path_to_domain_dir and path_to_subdomain_dir should be replaced by actual paths as per your server configuration.

If your blog is high traffic blog, then you may open shell first and type such command in advance. Please DO NOT hit enter before performing step 1.

Also DO NOT attempt moving files using FTP clients.

ADVERTISEMENT

Copying files:

This is for users who do not have shell access or have Windows server. This is good for high traffic site also.

Copy all files from one location to another location via FTP. Alternatively, you can use shell command to copy files if reason for this approach is high traffic to your site.

How you do this is your choice!

Once all your blog files are available at new location and you done with configuring wordpress as mentioned in step 1, you now either waiting on an error page, wordpress login page or settings page again.

ADVERTISEMENT

Just refresh no matter what is next to your eyes. You should see now your wordpress blog at new location. If you don’t contact me ASAP, with as much details possible.

3. Creating/Updating .htaccess file to preserve permalinks

This part is essential to maintain permalinks and SEO juice. Again this is divided in two ways depending on your goal.

Moving from a subdirectory to a subdomain:

Under root directory of your site (this is different than root directory of your blog), create (or update if already exist) a .htaccess file. You need to add only 3 lines to it as shown in following example:

Options +FollowSymlinks
RewriteEngine on
RewriteRule ^blog/(.*) http://blog.orkutfeeds.com/$1 [R=301,NC]

Please make 2 change to last line:

  • If your blogs’ subdirecotry have different name like wordpress, then replace first occurrence of blog with its name. (Ex: For wordpress, change ^blog/ to ^wordpress/)
  • Replace http://blog.orkutfeeds.com/ with your subdomain URL. DO NOT forget trailing slash (/).

Also delete or rename ‘blog’ subdirectory for .htaccess file to work.

Moving from a subdomain to a subdirectory:

Under subdomains root directory, create (or update if already exist) a .htaccess file. You need to add only 3 lines to it as shown in following example:

Options +FollowSymlinks
RewriteEngine on
RewriteRule (.*) http://www.orkutfeeds.com/blog/$1 [R=301,NC]

Please make 1 change to last line:

  • Replace http://www.orkutfeeds.com/blog with your new blog URL. DO NOT forget trailing slash (/).

Thats All! Now all permalinks, including links indexed by Search Engines should work fine.

Ideally, if you can perform all above steps at the same time, the whole process will go unnoticed without any downtime.

If you have any questions/suggestions please feel free to use comment form below.

If you like this post, please check our ongoing series on best WordPress Plugins.

Categories
Tutorial

Enabling CURL on Windows+PHP+Apache Machine!

This is for all php programmers using Windows.

If you are planning to use CURL library on PHP then you may encounter an error like below.

Fatal error: Call to undefined function curl_init() in F:projorkutfeedstrunkindex.php on line 15

I encountered above while developing orkutfeeds.

ADVERTISEMENT

Curl is by default not enabled on PHP on Windows although it is there. So to enable this go through following steps…

  1. Locate php.ini file. Its under directory where you installed PHP. On my machine its path is: C:wampbinphpphp5.2.5php.ini
  2. Once you find that file search for extension=php_curl.dll line
  3. There you will find a semicolon (;) before above line. Just remove it and save the change. That’s it!

If you have started webserver already then, you need to restart it again so that CURL extension gets loaded.

I found this while reading notes on PHPs’ official CURL page. This was posted by Lancelot du Lac.

In case your search for extension=php_curl.dll fails you may go through the steps mentioned by Tony Spencer.

Categories
Tutorial

Setting Up Firefox as IDE for Firefox Extension Development! [Firefox Developers]

This article is intended for all geeks who are working on firefox extension development! If you are new to this then you may want to start with shortest tutorial for firefox extension development!

This is small but important tutorial for those who seriously want to develop firefox extensions. As there is no good IDE for developing firefox extension you have to change your firefox itself so that it can act like IDE! With proper settings and few extensions you can really reduce extension development time and get a nice debugging environment.

Following points have been covered in this article:

  • Setup a different profile for extension development
  • Development Preferences
  • Development Extensions
  • Live Extension Development
  • Things to skip
ADVERTISEMENT

 

#Setup a different profile for extension development

This is first thing to do. Creating separate profiles for extension development saves you from personal data loss which may result from accidental crashes. Also points explained below will make your firefox slow and bulky which is not desirable for day-2-day browsing specially when you use sites based on AJAX like Gmail!

If you know how to use multiple profiles in firefox then create a new profile right now for extension development. If you are new then you can read our earlier article to do this. Also as always there is an official doc which explains this topic.

ADVERTISEMENT

If you are interested in my extension development profile then you can download it from here! (Size: ~4.0 MB)

 

#Development Preferences

These are basically settings which you can change by visiting about:config page. Just type about:config in address bar and hit enter. You will see lots of settings there. Now use search feature to find following settings and change their values if needed. If a search returns no result right click in windows to create a new setting. If you need help regarding this, please refer official Mozilla doc – Editing Configuration Files.

ADVERTISEMENT

Following is list of setting = value pair. If you are new, just do it without bothering too much.

  • javascript.options.showInConsole = true. Logs errors in chrome files to the Error Console.
  • nglayout.debug.disable_xul_cache = true. Disables the XUL cache so that changes to windows and dialogs do not require a restart.
  • browser.dom.window.dump.enabled = true. Enables the use of the dump() statement to print to the standard console. See window.dump for more info.
  • javascript.options.strict = true. Enables strict JavaScript warnings in the Error Console.
  • browser.cache.memory.enable = false. Disables caching in main memory i.e. RAM.
  • browser.cache.disk.enable = false. Disables caching on secondary storage i.e. hard-drive in most cases.

Last two are not present in official doc. They reduce performance but better to do them for live extension development as explained later. Also the performance hit can be and must be offset by creating a new profile for extension development as explained above.

 

ADVERTISEMENT

#Development Extensions

There are lots of extensions which can make extension development process pretty easy! Complied below is list from official docs and my experience over the time!

>> From official doc

>> Recommendations

ADVERTISEMENT

This is by no mean a complete list. You may find some of these useless at this point but what you really need is mainly depend on goals of your extensions. You may like to bookmark official developers extension listing. Alternately you can add it to your search toolbar.

 

#Live Extension Development

Do you follow following sequence?

  1. Edit Extension.
  2. Package it into XPI.
  3. Install edited extension.
  4. Restart Firefox.

If yes, then you can’t go far!

At this point you must switch to live extension development. This way you can skip packaging/installation steps always and restarting step most of the time!

To do this, first navigate to folder named extensions where all installed extensions are stored. extensions folder can be found in path like <profiles_folder>/<profile_name>/extensions. (Help on finding profile folder)

Once in extensions folder, you will find many subfolders. Each of these corresponds to one extension and folder names indicate extensions guid. Now if your extension is already installed then you will see a folder with its guid name. Jump in it. Or just create a new folder with its name equal to guid under extensions folder for new extension and start developing right in that folder.

Now important point is, changes made to files under extension folders are reflected instantly without packaging or installation. Still you may need to restart firefox depending on change you have made! A slightly different approach is taken by Jonah Bishop at borngeek.

 

#Things to skip

This is little unrelated to this topic but nevertheless important as a beginner. Many articles including official talks about deploying extensions into JAR files. I personally against it as JAR files complicates the process of development as well as maintenance with no considerable benefit.

Also there is a complicated process called signing XPI which is really not essential at beginners level!

While surfing, you will come across many topics which can be skipped without any problem to save your time as well as confusion.

 

Finally there is no as such hardware requirement but consider having atleast 1 GB RAM as extensions like Venkman are memory hungry.

That’s it! If you have any query regarding this or any other problem feel free to use comments form below. Please avoid contacting via email/chat for generic problem as open discussion here can help others too.

 

Credits: Mozilla’s official article – Setting up extension development environment & many other docs are used while writing this.

Categories
Reviews

Online C, Java, Javascript, JSON, PHP, Perl, SQL & other Source Code beautifier (formatter)

Many times you see source code which is very hard to read due to lack of proper formatting. Many of my friends who are working on various third-party programs on orkut from time-to-time needed to swim through highly unformatted javascript codes! 1000 lines of code written without any line brakes, forget about whitespaces & indentations. While reasons to do this may include security and causing obsfucation for professional sites even careless programming makes code written by on programmer hard to understand by other. If you ever encountered codes like these then you might have tried to clean them manually with much of fatigue, waste of time and in the end poor results.

Now Here comes list of online beautifiers classified according to programming languages. Some item may be repeated if it works for more than one language!

Javascript:

ADVERTISEMENT

 

C++, C#, Java:

 

PHP, Perl, CSS

SQL:

JSON:

 

Personally I use http://elfz.laacz.lv/beautify/? for javascript formatting and PrettyPrinter for rest (PHP, Java, C++, C, Perl, CSS).

If you have anything to contribute to this list please use comment to post it! 🙂

Categories
News

Orkut is coming out of sandbox! Submit your Orkut Apps!

If you are new to OpenSocial and Sandbox, then you may start with Beginners Guide To OpenSocial & Orkut Sandbox! It covers all FAQ!

Orkut is enabling developers to make their social applications available to orkut users. OpenSocial developers can submit their completed applications till Feb. 15

Later this month,  if your app passes Orkut testes and score enough it will be added to the application directory.

ADVERTISEMENT

Arne Roomann-Kurrik at Official OpenSocial blog quoted,

In order to be accepted into the directory, submitted applications must:

  • Function correctly. No 404s or broken links.
  • Be social OR self-expressive.
  • Not reveal personal data, like email (which is not delivered by the API).
  • Follow the Orkut terms of service. No violent or illegal content, nudity, or hate speech.

Also an event is scheduled to help & support opensocial developers at Googleplex – Googles Headquarter in Mountain View, CA and via video conferencing in New York. The event which is named orkut hackathons is on Feb. 14-15 from 10 am-6 pm. For  more information or to RSVP, please email hackathon.rsvp@gmail.com.

Some Useful Links:

Categories
Tutorial

Blogger To WordPress Traffic & Permalinks Redirection Plugin

Major Update: This plugin’s new version has been released with many new features like:

  • Zero changes requires on WordPress-side. Plugin handles everything automatically on WordPress.
  • New configuration wizard help you setup redirection without much efforts.
  • Supports importing from multiple Blogger.com blogs.
  • Add supports for “rel=canonical” & “meta-refresh” tags on Blogger.com which will speed-up redirection. This will help search engine update their index faster.

Link: Blogger to WordPress Redirection Plugin


ADVERTISEMENT

Update: This plugin maintains permalinks but in case you want to preserve Google Pagerank and other search engine ranking, please read this new complete tutorial first.


If you have imported your blog from blogger (blogspot.com) then you might be redirecting visitors from your old blogspot blog to your new wordpress blogs HOMEPAGE. While this approach ensures that you get all the traffic redirected from your old blog to new blog, a visitor may feel lost! What if a person is referred to your old blog via search engine or other link listings?

So this plugin just takes care of this part. It checks for which post people were looking on old blog and then redirect them to same post but on new blog! See following picture which will give you brief idea about what you can accomplish using this plugin…

This plugin assumes following things:

  • You used wordpress blog importer while importing your blogspot beta blog.
  • You put redirection code in your old blogspot blog. An example of code is attached below. I strongly recommend using it only.
  • You have imported only one blog. In next version I will remove this restriction so that you can import (or say merge) two or more blogspot blog into one new wordpress blog.
ADVERTISEMENT

Installation (Blogger Blogspot Part):

  1. Log into your blogger account.
  2. Select old blogspot blogs template/layout. If you are using new custom layout, use “Revert to Classic Template” option on Edit HTML.
  3. Go to “Edit HTML” tab.
  4. Put following codes there with one important change and save changes.
ADVERTISEMENT

(Important: Replace http://www.devilsworkshop.rsites.dev6.rt.gw/ in following code with your wordpress blog URL)

<html>
<head>
<script LANGUAGE="JavaScript">
<!--
window.location.replace("http://www.devilsworkshop.rsites.dev6.rt.gw/");
-->
</script>
<noscript>
<meta http-equiv="Refresh" content="10; URL=http://www.devilsworkshop.rsites.dev6.rt.gw/"/>
<meta http-equiv="expires" content="10"/>
<meta name="Description" content="301 moved permanently"/>
<META NAME="ROBOTS" CONTENT="NOINDEX, FOLLOW"/>
<META NAME="GOOGLEBOT" CONTENT="NOINDEX, FOLLOW"/>
</noscript>
<title>301 moved permanently</title>
</head>
<body>
<center>
<h1>Devils Workshop</h1>
<p>has been moved to new address</p>
<a href=" http://www.devilsworkshop.rsites.dev6.rt.gw"> <h1>http://www.devilsworkshop.rsites.dev6.rt.gw</h1></a>
<p>Sorry for inconvenience... </p>
</center>
</body>
</html>

Installation (WordPress Part):

  1. Click here to download Blogger To WordPress 1-2-1 Redirection Plugin. A file rbBloggerToWordpress.zip to your PC. Unzip it.
  2. Upload rbBloggerToWordpress.php into ‘wp-content/plugins’ folder.
  3. Go to plugins option under wordpress’s Admin panel. You will see a “Blogger To WordPress Redirector” Plugin Listed there.
  4. WAIT! Do NOT click Activate. First Click Edit.
  5. On next screen put your old blogspot blog address next to $oldBlogURL variable! For ease search rb286.blogspot.com and replace it with your blogspot address. Sorry for this manual work, I will automate this step in next version.
  6. Then click Update File link their to save changes.
  7. Go back to plugins page and this time Activate the plugin!

That’s it! This plugin will now onwards map your old blogspot post to new wordpress posts on 1-to-1 basis.

Known Issues:

ADVERTISEMENT
  • Popular desktop blogging client Windows Live Writer stops working if you use this plugin. But there is temporary workaround. Disable the plugin & paste following code into current templates index.php [i.e. Main Index Template] before everything else! [Path: Admin Dashboard >> Design >> Theme Editor]

#Code: [Note: Replace rb286.blogspot.com with your old Blogspot address]

<!--?php
oldBlogURL = "rb286.blogspot.com";
$ref = $_SERVER['HTTP_REFERER'];
$refarr = explode("/", $ref);
if ($refarr[2] == $oldBlogURL ){
  $bloggerurl = '/'.$refarr[3].'/'.$refarr[4].'/'.$refarr[5];
  $sqlstr = " SELECT wposts.guid FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta WHERE wposts.ID = wpostmeta.post_id AND wpostmeta.meta_key = 'blogger_permalink' AND wpostmeta.meta_value = '".$bloggerurl."' ";
  $wpurl = $wpdb->get_results($sqlstr, ARRAY_N);
  if ($wpurl){
      header( 'Location: '.$wpurl[0][0].' ') ;
      exit;
  }
}
?>
ADVERTISEMENT

Example :: How this plugin works?

First note that,  there are two parts – blogger part and wordpress part.

Also for the sake of simplicity lets assume old.blogspot.com/cool-post is mapped to new-wordpress.com/cool-post

Now observe journey of a user…

  1. User requests old post – old.blogspot.com/cool-post
  2. old.blogspot.com send user to new-wordpress.com.
  3. Now at new-wordpress.com, second parts get activated as visitor is coming from old.blogspot.com.
  4. Second part checks for HTTP Referrer information from where it finds URL of old.blogspot.com/cool-post.
  5. Using this information second part at wordpress finds new-wordpress.com/cool-post and sends it to browser.

In fact, the whole process is so transparent that if a user have address bar disabled he will never notice any sign of redirection process. 😉

About Javascript code at blogger end… its for non-standard browsers who don’t respect meta tags.

About NOINDEX FOLLOW, it tells crawler not to index blogspot page but FOLLOW redirect. Also NOINDEX will instruct crawler to drop already indexed version of page. We need to use NOINDEX because new wordpress post have same content as old blogspot post. This is to ensure that we explicitly handles duplicate content problem.

Let me know if I am missing something as this is my first wordpress plugin.

Credits: I am grateful to Charles and Live HTTP headers firefox extension for their help while coding this plugin!

[Updated: 2008, July 20 – After my  Jimmy’s comment]

Categories
Tips

Beginners Guide To OpenSocial & Orkut Sandbox! [covering FAQ]

In this post, I will try to clear your doubts on orkut sandbox and opensocial API. In the end I will be listing resources that you can use and bookmark!

#What is OpenSocial?

From wikipedia,

ADVERTISEMENT

OpenSocial is a set of common application programming interfaces (APIs) for web-based social network applications, developed by Google, and released November 1, 2007. Applications implementing the OpenSocial APIs will be interoperable with any social network system that supports them, including features on sites such as MySpace and Friendster.

Except facebook almost all social networking sites are using OpenSocial. Means you can safely assume if you write application for orkut using OpenSocial API it will work on other sites (like MySpace, LinkedIn, etc) almost without change! 🙂

#What is orkut sandbox?

First lets get relevant definition of sandbox from wikipedia

ADVERTISEMENT

"The term sandbox is commonly used in the development of Web services to refer to a mirrored production environment for use by external developers. Typically, a third-party developer will develop an create an application that will use a web service from the sandbox, which is used to allow third-party team to validate their code before migrating it to the production environment"

So think of Orkut Sandbox as orkut mirror where you can write application using Open Social API. Its like creating a fake orkut account to test new orkut hack. Think of sandbox as a fake profile with some features added/removed and created by orkut itself for you to test applications!

#Cool… How to signup for orkut sandbox?

ADVERTISEMENT

By default sandbox access is disabled for a orkut account. You can request access to sandbox using orkut sandbox sign up form. The sandbox access is completely free and will require you to have orkut account beforehand.

After submitting sign-up form you get mail from Google (normally in 2-3 days) indicating status of your request.

#How to access sandbox? Where it is?

Sandbox is extension to your existing orkut account! After receiving confirmation mail from google you can just log on to http://sandbox.orkut.com to enter into sandbox. Also you can modify any orkut pages’ URL to get its view from sandbox.

ADVERTISEMENT

Example:

http://www.orkut.com/scrapbook.aspx?uid=[some_num]

will become..

http://sandbox.orkut.com/scrapbook.aspx?uid=[some_num]

This small URL change once resulted in scrapbook hack which enabled people to read locked scrapbook via sandbox!

ADVERTISEMENT

 

#Sandbox Limitation

OpenSocial API Calls will operate on sandbox whitelisted friends only. This means to test your applications you need either your friends to gain sandbox access or add people who have access to sandbox as friends. There is an orkut sandbox community where you can find people with sandbox access and add them.

This limitation is enforced for security reasons as explained by Arne Roomann-Kurrik!

Also private information like email addresses of users can not be accessed! So spammers do not think about sandbox as a way for your evil intentions 🙂

#Resources

If you are not familiar with words like sandbox, API use following wikipedia links…

Best starting point for developers…

Worth bookmarking….

Finally if you need to communicate…

Let me know if I missed anything! Happy coding… 🙂

Categories
Reviews

3 Free Sites for Downloading Old Versions of your favorite Software!

Sometimes upgrading to a newer version can be a good thing. Other times, your computer may not be compatible with the new version, the new version is bloated, or all the options you liked are no longer available.

There could be many reasons where you like old version of a software and want to use it only! If you maintain your favorite softwares in their favorite versions thats fine but often you will find yourself browsing website of a software company for old versions of a particular software. Unfortunately not all software provider are interested in keeping old version available for downloads.

Here comes to rescue following 3 sites whose only purpose is to maintain old versions for free download. These three are almost identical in operation (in fact I had hard time to figure out differences to write about)

1. OldApps.com (Exclusively for Mac OS)

ADVERTISEMENT

2. OldVersion.com

  • Softwares are not sorted but seems to maintain largest collection. Also noticed few Linux softwares.

3. Old-Versions.net

ADVERTISEMENT
  • It maintains a drop-down menu in right sidebar through which you can really reach your favorite softwares version page with just one-click (and without typing too!)!

All 3 have a contribute section so that you can upload old versions of softwares you posses to their repository. Also OldApps and OldVersion have forums where you can discuss various issues related to software versions, etc!

Finally on personal note, few software I havent upgraded over a year includes…

  • Winamp v2.73 – I love mplayer for movies. So why to go for winamp with video capability! 😉
  • ACDSee v3.0 – Image browsing application. Reason: New Versions are bulky and memory consuming.

Please notify us if you find any other site which you think can be added to this list! 🙂

Categories
Tips

Firefox: 4 Ways to Make Old Extensions Compatible with Firefox 2.0

With Firefox 2.0, many of old extensions facing compatibility problem!

Gleb Reys posted 3-ways to make old firefox extensions compatible with firefox 2.0! The three way covers up so many details that u will end up either making ur old extensions compatible with firefox or removing them for sure!

The 4-th way I’m presenting here based on 3rd way! This is for all firefox extensions developers! Just follow the steps below…

1. Open the directory of your extensions source code n locate “install.rdf”.
2. Look for following fields…

em:minVersion=”1.5″
em:maxVersion=”1.5.0.*”

3. em:maxVersion field specifies the maximum firefox version with which your extension is compatible.
4. Just replace “1.5.0.with “2.0.“.
5.
Save “install.rdf” n rebuild your extension! Thats it!

A word of caution!
Don t forget to test your extension before releasing although this will work most of the times!

Related Link:
Click here to download Firefox 2.0+!