How To: Invite ALL of Your Facebook Friends to Google Plus At Once

Image representing Google as depicted in Crunc...

Image via CrunchBase

Using a neat little trick, I managed to send everyone on my Facebook friend list a Google+ invite. In this post, I’ll show you how to do that. It’s actually quite simple. If you don’t have a GMail account, this will still work for small amounts of contacts, but you need to use a GMail account to process and invite all of your contacts at once.  First, if you don’t already have a Yahoo account, sign up for one. Otherwise, sign in and go to Yahoo Mail. The reason this works is because Yahoo and Facebook have some kind of partnership. Once logged in, go to the “Contacts” tab. Click “Import Contacts”, and choose the “Facebook” option. Allow Yahoo access to your Facebook contacts. On my account, it only imported 100 contacts the first time. After the second try, I had all 257 of my Facebook contacts imported. Now that you have your contacts imported, go back to the “Contacts” tab. Click “Actions”, and choose “Export All…”. When asked, export as a “Yahoo! CSV” file, and remember where you saved that. You will need it later. Now go to Google Contacts. Create a new group called “Facebook”. Once you have a “Facebook” group, click the “Import” link on the upper right of the page. Select the Yahoo .csv file, and make sure to choose to import it into the newly created “Facebook” group. Now that you have all of your contacts imported, if you don’t have GMail, select all of your contacts and choose “Email”, otherwise go to GMail and login to that. In GMail, click “Contacts” and then click the “Facebook” group. Click the checkbox above the list of contacts to select them all at once. Now click the “Email” button. You will now see all of your contacts in the “To” field of GMail or your email client. Copy the entire list, and paste it into the Google+ invite form. Click invite. Congratulations, you just invited all of your Facebook friends to join Google+.

How To Make a Beeping Timer Using Bash Script and Ubuntu Linux

I had my wisdom teeth removed this morning, and I’ve more or less been bedridden with my laptop, so I decided to kill time and keep my mind off of the pain by writing a script to beep whenever I have to alternate between having ice on my face and vice versa. I’m supposed to switch between the two every 20 minutes, which is a pain to remember and keep track of, so why not have the computer do that for me? Most of the work is already done for me in readily available tools, like Linux‘s “date” command, and the MOC console audio player. The only “real” work I had to do was write a few simple conditional statements, look into command line arguments for the programs used (using man pages), and creating a beeping sound using Audacity. This took me less than 30 minutes total, and I figured someone somewhere might find it useful or interesting, so I decided to write a tutorial about it and describe how I did it. A lot of this is geared towards those without much programming experience, so it might be useful in teaching the basics of programming and turning logic into code. Note: I realize there is a “beep” command available, but my laptop does not have a built-in speaker that works with that, so this is a very easy alternative, and it’s more compatible, too.

Because the easiest step is creating the audio file, I’ll start with that. If you’re just looking for a short beeping sound, and you don’t feel like opening up Audacity, the file I used can be downloaded below.

Audio File Used: 440Hz Beep for 3 Seconds

This is actually incredibly easy. If you don’t already have Audacity, download and install it. Now open it up, and choose “Tone” under the “Generate” menu. For me, the settings I used were Waveform: Sine, Frequency: 440Hz, Amplitude: 1, Duration: 3 Seconds. This will quickly generate the beeping sound. Now you need to export this in a format playable by MOC. To do this, go to File > Export… and set the file type to “Ogg Vorbis Files“. Now save the file as something.ogg in the same directory you want the script to be in. For my script, the file name I used is “beep-440-3s.ogg”, but the name really doesn’t matter. I don’t recommend using spaces as you probably have to escape them in your script, which is a pain that can easily be avoided.

Now, if you don’t already have MOC console audio player installed, you need to install it (or another tool of your choosing) in order to play the audio file from the command line. To get MOC audio player in Ubuntu or Debian Linux, you can type the following command in a terminal, assuming the debian package “moc” is available in your configured software repositories:

sudo apt-get install moc

This method requires super-user (administrative) permissions, unfortunately, but that probably won’t be a problem for you. For more information on the sudo command, see Ubuntu Linux, Day 18: What Is This ‘sudo’ You Speak Of? (pcworld.com). Excuse me for a second, my timer just went off… now that we got that over with, let’s get started on coding the script!

Now, In my case, because I have to switch between ice and no ice every 20 minutes, there are three times that I switch between the two as 60 divided by 20 is 3. Because this is an odd number, the range minutes that I will or will not have a bag of ice on my face alternates every hour. To determine whether or not I should have a bag of ice on my face in a given 20 minutes, we can use the modulus operator, which is used to determine the remainder of a division operation. If the modulus operator returns a zero, then there is no remainder (obviously). By getting the remainder of dividing the number of the hour by 2, we can tell if the current hour is even if the remainder is zero. The way I wrote this script isn’t the most efficient way of doing this, but I wanted to create something that worked quickly without spending too much time on it. Also, yes, I realize I could’ve done something incredibly simple, like using the watch command to tell me when to alternate between ice and no ice, but this was more fun to code, mostly for practice, and it works for me. An example of how I would use the watch command instead is to have it wait 20 minutes (the argument ‘n’, which is the time to wait, is in seconds, so there are 1200 seconds in 20 minutes), and play the sound after that amount of time. This can be done with the following command from within the folder where the beep audio file is stored, substituting the duration and the file name with the ones you used/need:

watch -n 1200 mocp -l beep-440-3s.ogg

This will wait 20 minutes from the time of starting the command and then beep, repeating every 20 minutes. However, the title of this guide is “How To Make a Beeping Timer Using Bash Script and Ubuntu”, so I’m going to show you how to do that.

First, we’ll start with the obligatory shebang line:

#!/bin/bash

Because the entire script will be repeated indefinitely, until closed (such as using Ctrl + C), we want the main contents of our script to be in a while loop. The bash equivalent of a “while (true)” loop is “while [ 1 ]“, so the entire body of the script will be enclosed in that loop. Instead of brackets, while loops in bash are terminated with “do” at the beginning, and “done” at the end. The most obvious challenge we need to focus on is getting the current hour and minute in a format that’s incredibly easy to parse and work with. Linux’s “date” command works wonderfully for this. It does nearly all of the work for you, all you have to do is tell it how to format the date. If you look through the man pages for the date command, you can see that you’re able to specify how to format the date. All we’re interested in is the current hour (%k) and minutes (%M). To retrieve the hour from the date command, you simply type “date +%k”, where the formatting we want is after the plus sign. Go ahead and try that. The command to retrieve the current time in minutes is the same thing, substituting “k” for “M”. The letters are case-sensitive. When initializing a variable using bash script, it’s possible to set the variable to the return value (output) of a command using back-ticks. So, to get the current hour and minute, our code looks like this:

HOUR=`date +%k`

MIN=`date +%M`

Now that we have the hour and the minutes, we need to check to see if we should play the beep audio file or not. If the remainder of dividing the current minutes by 20 is zero, then we should be playing the file. The code for this is as follows:

let REM=”$MIN % 20″

if [ $REM = 0 ];

then

mocp -l beep-440-3s.ogg

fi

The “-l” argument of the mocp command tells MOC to just play the audio files specified in the command line arguments without messing with playlists, etc. Now that we have the beep working, we could consider the script done, as it goes off every at :00, :20, and :40 after the hour, but other that the fact that it’s obvious if you should put on ice or take it off, it’s a coding challenge to determine which one, so I decided to make the program say whether you should put ice on or vice versa. The first thing I did is realized that there are three times in an hour where I alternate between ice or not. Two of the times are the same except for the middle time at 20 minutes. Because 20 / 20 is one, we can check if the current minutes divided by 20 is 1 and display whether or not to put ice on depending on if the hour is an even number or not. In my code, I refer to the current minute divided by 20 with a truncated remainder as the current “set” number. The code for this is easy to write:

let SET=”($MIN-$REM)/20″

For debugging information, I list the current hour, minute, set, and whether  I should have ice on or not on the screen. This is also easy to code:

echo -n “Hour: $HOUR Min: $MIN Set: $SET “

In the string echoed to the console and the mathematical expressions, a variable name preceded by a dollar sign ($) is replaced with the value of that variable and evaluated as such. The -n argument of the “echo” command just tells echo not to append a new line character to the end of the string it prints to the output stream (in this case the console). The reason for this is because later in this script I echo whether or not I need to have ice on or off, and it looks neater to have it all on the same line. To determine whether the hour is an even number or not, we get the remainder of dividing the hour by two. If the remainder is zero, the hour is even. We can then use that to help determine whether we alternate cycles this hour. The code for this is incredibly simple:

let hrem=”$HOUR % 2″

As stated earlier, if the set is the middle set (set ’1′, at 20 minutes after the hour), whether or not I need to use ice is different than the other two sets. Using that logic as well as the fact that the fact that the cycles alternate each hour, we can piece together the logic using very basic conditional statements:

if [ $SET -ne 1 ]; then

if [ $hrem -ne 0 ]; then

echo “Ice On”

else

echo “Ice Off”

fi

else

if [ $hrem -ne 0 ]; then

echo “Ice Off”

else

echo “Ice On”

fi

fi

If you aren’t familiar with bash syntax, “-ne” is short for “is not equal to”, which is usually expressed in other languages using “!=”, or “not” before a condition. Finally, to prevent a lot of redundant output, we will use the sleep command to wait a minute (60 seconds in the command) before the next iteration (repetition) of the while loop:

sleep 60s #wait 1 minute

And we’re finally done coding the script! Now, we just need to save the script in the same directory as the beep audio file, with the “.sh” file extension and set it as executable. To do that, you can use the Properties dialog, or just do it with the command prompt using the following command:

chmod +x ice-timer-script.sh

Now you can run the script using the command “sh ice-timer-script.sh“. I hope that somebody finds this tutorial useful. Writing this certainly helped keep me busy, since I’ve been in bed for the majority of the day. If you have any questions or feel that anything needs clarification, feel free to leave a comment! The final script used in this tutorial can be found at http://code.dylanmtaylor.com/bash/ice-timer-script.sh.

How to Reset GNOME Panels to Defaults

Recently, I encountered an unusual graphics corruption bug in my lower GNOME panel. The panel still worked perfectly fine, but it was covered in unusual corruption artefacts, and it looked unsightly. I don’t think many people will actually have this problem, but it was an incredibly simple and easy fix, so I decided to share it on my blog. This may also be useful if you manage to mess up your panel layout, and you just want to start from a fresh slate. The fix is simple: just delete the directory where your GNOME panel configuration files are stored, and GNOME will automatically create a new configuration folder using the default settings the next time you login. The quickest way to do this (in my opinion) is through the terminal. Simply open up a terminal, and paste in the following command:

rm -rfv $HOME/.gconf/apps/panel

Now log out and log back in. Your GNOME panel settings will be reset to their defaults. Enjoy! :)

Fixing Lexmark Printer Driver Installation in Ubuntu 11.04

Recently I just installed the Lexmark printer driver in my 64-bit Ubuntu 11.04 installation. As you may or may not notice, the installer is broken by default in Ubuntu 11.04, and it just exits with an error message, saying

Lua error detected: While parsing install.lua: config/run.lua:1374: attempt to index global ‘ownhership’ (a nil value)

After playing with the installer, I finally got it to work perfectly, so I emailed the Lexmark support team to let them know how to fix this, but for now, I’m going to share what you need to do on my blog.

First, you need to extract the files for the installer. To do this, you need to run

./lexmark-inkjet-legacy-wJRE-1.0-1.amd64.deb.sh –noexec –keep

It’s worth noting that there are two hyphens before noexec and keep. Once you run that command, the files for the installer will be extracted to the tmp folder in the current working directory. For now, just type cd tmp and press enter. Now, open up a text editor, such as gedit and navigate to the config folder in the tmp folder we just extracted. Open up the file “run.lua”. The problem is that Lexmark misspelled ownership as ownhership, which broke the installer. Around line 1484, you will find a line that says

if tonumber(ownhership[1]) == 0 then

delete the errant h in the word ownership and save the file. Now, go back to your terminal and run sudo sh startupinstaller.sh in the tmp folder. The installer will work as expected now.

Update: Special thanks to Mathieu Triclot for your $5 donation! Glad I could help! :)

Closer to a Proper Froyo Limit Removal Fix

So, I recently managed to get the limit removed (manually) in the Android 2.2 emulator found in the Android SDK. This proves that it is possible, and I hope to have an automated fix out soon. For those of you who can’t wait (rooted device required) — try this:

  • Download the Android SDK
  • Put your device into development mode (Go to Settings > Applications > Development, and make sure USB Debugging is enabled)
  • Plug your device into your computer’s USB port
  • Make sure you are connected to your device by running adb devices
  • Use cd to change directory to the tools directory of the SDK
  • Run adb shell
  • Type su and hit enter
  • Type remount rw and hit enter. Depending on your phone, this may not work, and you might get a command not found error. If so, try “mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system“. If you are testing this on the Android Emulator, the command you want is “mount -o remount,rw -t yaffs2 /dev/block/mtdblock0 /system“. If none of these commands work, look for your device’s command to remount the filesystem in read-write mode by searching on Google, and type that instead. This step in not optional. It will not work if you skip this step.
  • Now type exit and hit enter, repeat if you aren’t out of adb shell yet
  • Type adb pull /data/data/com.android.providers.settings/databases/settings.db and hit enter
    • If you get an error saying “failed to copy ‘/data/data/com.android.providers.settings/databases/settings.db’ to ‘./settings.db’: Permission denied”, make sure that you remounted your filesystem in read-write mode. This could be the problem. If it still does not work after you make sure that you remounted your filesystem properly, try these steps which worked for me:
      • Go back into adb shell
      • Type su and hit enter to get root access
      • Type, letter for letter, “cat /data/data/com.android.providers.settings/databases/settings.db > /data/local/settings.db” and hit enter
      • Now type exit twice to get out of adb shell
      • In your regular terminal (not adb shell) type “adb pull /data/local/settings.db” and hit enter.
  • Type sqlite3 settings.db and hit enter
  • Type (letter for letter) these lines, hitting enter after each one:
INSERT INTO gservices (name, value) VALUES ('sms_outgoing_check_max_count', 999999999);
INSERT INTO secure (name, value) VALUES ('sms_outgoing_check_max_count', 999999999);
INSERT INTO gservices (name, value) VALUES ('sms_outgoing_check_interval_ms', 0);
INSERT INTO secure (name, value) VALUES ('sms_outgoing_check_interval_ms', 0);
.quit
  • If you are on Android 2.2 or newer, it is perfectly normal to get “no such table” error messages when entering the gservices lines. Just ignore those. It will still work.
  • You should be out of the sqlite editor, and back to your shell.
  • Type adb push settings.db /data/local/ and hit enter
  • Now, go back into adb shell (just type adb shell and hit enter)
  • Verify that you have a # in your shell(not a $), which means that you have root access.
  • If you do not have a # in your shell, try typing su
  • Type cd /data/local to get to the directory where we just stored the modified settings database
  • type ls to list the files in the directory, and verify that settings.db is in the list of files
  • Now, letter for letter, type cat settings.db > /data/data/com.android.providers.settings/databases/settings.db and hit enter
  • Nothing should appear on the screen. This is perfectly fine.
  • Now, let’s verify that the file was written properly before rebooting the phone…
  • Type cmp -l /data/local/settings.db /data/data/com.android.providers.settings/databases/settings.db
  • Nothing should come up from that either. If something does, the database was not copied properly. Go back to the last cat command step. Otherwise, your database has been modified successfully. Congratulations!
  • Now, exit the shell again, by typing exit and hitting enter until you are no longer in adb shell, just like last time.
  • The settings file should be updated on your device. This will not be applied until you reboot your device.
  • To reboot your phone, type adb reboot and hit enter.

I haven’t tried that method, since automatic removal works perfectly on my Samsung Epic 4G running Android 2.1, but let me know if that works for you by leaving a comment on this post, or by sending me an email. This method has been updated, and it works perfectly on my Samsung Epic 4G running a leaked ROM of Android 2.2.

UPDATE: I recently found out that WordPress changes certain characters slightly, which causes the SQLite commands above to not work properly. The SQLite commands are now in <pre> tags to prevent this from happening. This may be the reason that manual removal failed before for some users. Also, rather than pushing the file directly to the settings database, the guide is updated to push it to /data/local/ and overwrite it as root using cat.

UPDATE 2 (10/21/2010): I successfully got this working on someone’s phone, and they no longer have a sending limit (verified)! Special thanks to Jacob Miller for helping me out and for his patience while we tried commands on his Droid (Original), until we eventually got it working! :) This guide has been updated to reflect the changes in the process that were necessary in order to get it to work.

UPDATE 3 (11/12/2010): On my Epic 4G running the leaked Android 2.2 Froyo ROM, I was unable to pull the settings.db file directly. I updated the instructions to include a workaround that worked for me.

NOTE: I have tested this method on the Android 2.2 emulator three different times, and it worked each one. I want to automate the process on actual, rooted devices, but at the moment, it only works on 2.1 unfortunately.

adb push settings.db /data/data/com.android.providers.settings/databases/settings.db

How To Get Skype on a Non-Verizon Wireless Android Device

Skype Technologies S.A. logo

Image via Wikipedia

I don’t usually write how-to guides and tutorials on my blog, but this is a really cool (and useful) trick, and I just tried this recently on a friend’s AT&T HTC Aria phone, and it works. The reason that this is so important is because Skype Mobile  for Android/Blackberry devices  is currently exclusive to Verizon Wireless, and no devices (with the exception of the iPhone) on other carriers are supposed to have access to it. The software doesn’t work very well, but it’s better than nothing. Keep in mind that this is the “Lite” version of Skype, and it’s still in Beta. It’s really simple to do this, actually. You just need to go to the market URL for the unpublished Skype Lite Beta package, and download it to your phone. That being said, the application has a lot of issues, such as crashing, and it feels incomplete, so it may be better to just hold off on Skype mobile for the moment. For your convenience, here is a QR code to make downloading the Skype Lite Beta application easier for those of you who have a barcode scanning application on your Android powered device: