"Innovation comes only from readily and seamlessly sharing information rather than hoarding it."- Tom Peters
Development Blog

Development Blog

Using SocialCam without all the Facebook Mess

Don't you hate it when a website forces you to use Facebook for everything? SocialCam is yet another example. Using the bookmarklet below, you don't have to use Facebook anymore!

SocialCam Freedom - drag me into your bookmark toolbar and click when on Facebook or SocialCam

What do I do?

Simply click it once when on your Facebook news feed and all links will now work without needing the SocialCam app!

Simply click it when on a SocialCam webpage to view any videos in the sidebar without needing to log in!

Yes Pandora, I'm still Listening

Are you tired of having Pandora stop and wait for you to click "I'm still Listening" button? Well, drag the button below into your bookmarks, and when you start Pandora, click on it. Then, you'll never see that button again!

I'm Still Listening - drag me into your bookmark toolbar and click when viewing Pandora

How's it Work?

When Pandora revamped their interface a while back, they moved to an HTML based display. With that, it allows Javascript to interact with the controls. This script simply checks once a second if the button is there. If it is, it clicks on it. That's it!

Technical details: Pandora includes jQuery for use, so this bookmarklet uses that. The button is selectable because it has the CSS classes still_listening, button, and btn_bg. I find anything that has all three of those buttons and click on it! Pretty simple.

Starting Activity from Sleeping Device

Permissions Required

In order to wake up the device, you need to request the WAKE_LOCK permission. To do that, add this XML snippet into your AndroidManifest.xml.

<uses-permission android:name="android.permission.WAKE_LOCK" />

Waking up the Activity Using a Wake Lock

NOTE: I'm modifying the code found in Android - Creating an Alarm with AlarmManager.

Add this to your AlarmReceiverActivity:

private PowerManager.WakeLock wl;
public void onCreate(Bundle savedInstanceState) {
	PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
        wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");
       ... //The rest of the onCreate() is still the same (for now)

protected void onStop() {

So, what we're doing here is requesting a WAKE_LOCK from the operating system. This lock is a lock on CPU and must be released. That's why (in this case), I release the lock in the onStop for the activity. Feel free to move it to somewhere else, but you must be sure it gets released.

Android - Creating an Alarm with AlarmManager

There isn't a lot of good write-ups on how to use the AlarmManager, so here is an example that launches an Activity using the AlarmManager.

What's the AlarmManager used for?

The AlarmManager is used to schedule events or services at either a set time or a set interval. It's Android's "version" of the cron. In this case, we're going to set an alarm for five seconds after the app is launched.

What we're going to build

In order to use build this simple app, we're going to create only two classes. One will be for the Main Activity, and one will be for the Activity we want to launch with the Alarm. We will also have two simple layouts for each of the activities.

Creating input fields that only accept integers - jQuery

Wouldn't it be nice to force only certain characters into a text field? How about for a field asking for age? You would only want integers. Same with height, weight, or even a phone number. Well, here's a quick snippet that'll do just that!

$(document).ready(function() {
$("#inputField").keypress(function(event) {
return /\d/.test(String.fromCharCode(event.keyCode));

So, what's happening here? Well, it adds a keypress event to the input field with id "inputField" (feel free to change to whatever you need). Whenever a key is pressed, this function is fired. If the function returns false, the key pressed is not added to the input field. If it returns true, it is added.

The function is given an Event object, and the keyCode value is a numeric value. The String.fromCharCode converts that to the actual character that the user inputted. It is then tested if that character was an integer, using a regular expression test. If it is not an integer, false is returned, and the character is not added to the field! Pretty simple, huh?

The Easy way for Key Based Authentication for SSH

Why use a key-based system?

Using a key-based system makes it much faster, and even more secure to ssh into a server, and scp files onto a remote server. To do this is pretty easy...

Automatic Backup of MySQL Databases

This is a trick that works on a Linux system, as most servers are hosted using Linux. So, you would have to figure out how to change it if you are using Windows (sorry).

What are we going to do?

We will just create a simple bash script that will backup all databases, and we will create a cron job to do it for us on automatic intervals.

The Bash Script

You may first ask me, why do this in a bash script? Why not put it straight into a cronjob? Well, I'm doing it just to make it easier if you want to run other commands, or do one file per database. So, here's the script:


mysqldump -h localhost -u mikesir87 -pPASSWORD --all-databases > database.sql
gzip database.sql
mv database.sql.gz BACKUPS/`date +mysql-BACKUP.sql-%y-%m-%d.gz`

The first command, mysqldump, does a simple dump on the database. Since we give it the --all-databases flag, it grabs all databases that user has access to. The -h flag is for the host, which will probably be localhost. The -u flag is the username for the connection and the -p flag is for the user's password. Note that there is space between the flag and the password. If you're not familiar with Unix command lines, the > is what is called an IO Redirect.

Protecting Images using PHP and htaccess

Sources to check

In this article, we're going to tackle a few different tactics to safeguard images. But, let's first think about what ways people can get images.

  • Direct path - if a user knows the path to an image, they can simply go straight to it, and download the image.
  • Drag and drop - in most browsers today, you can simply drag and drop an image right onto your desktop.
  • Hotlinking - another website can link directly to your image
  • Screenshot - a visitor can simply take a screenshot of your page and crop the image.

How to fix them

So, now that we've established where our problems are, how can we fix them?

A few SEO notes


There are a lot of different tools and methods to use to help your site be noticed and found. Of course, I'm still working on some of these myself, but here's a few things I've learned so far. Post a comment about any other things you might have to offer!

Google Analytics

Google Analytics is a pretty powerful suite to help you understand the experience of your site's visitors. To get an account is free, and only requires you to add a Javascript file to your site pages. Most CMS's have plugins that make this easy.

Some of the features I look at are the sources of the visits. Google Analytics gives you a nice chart to help you get a quick glance of the source of the visits... such as this:

You can click on the graph to get it broken down. If you go into the Search Engine section, it'll even tell you what search terms were entered to get them to your page (helps having Google providing the software!).

CSS3: Drop Shadows

CSS3 is exciting stuff. I really like the drop shadow feature because I was tired of always having to create new PNG files just to get the effect. Also, it's a pain trying to get the bottom lined up, and the right side of a div to all look right with the shadow. What a relief it is to let the browser figure it all out!

So, what are the tags?

Just like the CSS3 rotating text, each browser has its own tag. I haven't figured it out for Opera yet, but I'm sure that's ok. Very few people are using it anyways, right? So...here's the tags.

-webkit-box-shadow: 10px 10px 25px #ccc;
-moz-box-shadow: 10px 10px 25px #ccc;

The first one, the filter is for IE (details), the webkit tag is for Chrome and Safari (details), and the moz-box-shadow tag is for Firefox (details).


Webkit and Mozilla

The properties are pretty simple. They pretty much go as follows: