Tag Archives: reference

No more Google AdSense plugin for WordPress + yellow background color on responsive ads

Not too long ago, I received an email from Google AdSense stating they are dropping their plugin for WordPress. Within the email, they provided two options in placing AdSense ads into WordPress sans the Google plugin. I was able to apply both methods to my site. I made a quick tutorial on how I did it. Check it out.

I encountered a problem with the responsive ads that were generated. If the ad chosen by Google was smaller than the size of the container, a bit of yellow shows. I figured I’d tweak the code generated by Google by adding "background-color:transparent" setting to the style attribute. I decided to go inline instead of tweaking the style sheet. My logic is: if I decide to change my theme, the inline code should stay the same, whereas, the external style sheet will update with the theme.

Multiple RSA key pairs using ssh-keygen & .ssh/config (Mac OS X tutorial)

I got tired of typing my password after ssh‘ing to remote servers. After some googling, I found the solution, the ssh-keygen command and ssh-copy-id command. ssh-keygen generates an rsa private/public key pair. Once you generate the keys, you’ll need to store the private key on your computer and the public key to the server. ssh-copy-id command is used to copy the rsa public key onto the remote server. This command will also create the necessary file and change the necessary permissions to make this all work.

I followed a tutorial from Ramesh Natarajan (http://goo.gl/fX68N). I got stuck on trying to copy the public key to the remote server. I’m on a Mac and apparently ssh-copy-id command is not built in. I found the Mac install (located at GitHub, MacPorts or Homebrew) and completed Ramesh’s tutorial. I was able to quickly connect to the remote server without typing in the password… How sweet is that?

All was good until I started to frequently connect to different servers. Ramesh’s tutorial covers a single rsa key pair. For security, it’s best to have a unique rsa key pair for each unique connection . After some searching, this can be accomplished by modifying the ssh-keygen command and using the config file located within the hidden .ssh directory.

I first began by creating another unique rsa key pair:

ssh-keygen -f ~/.ssh/id_rsa_userA -C "userA @ server1"
  • The -f flag specifies the filename of the key file. In the example, it is “id_rsa_userA“. The private key will be “id_rsa_userA” and the public key will be “id_rsa_userA.pub". As you can see from the absolute path, the files will be locate in the home directory and within a hidden .ssh folder.
  • The -C flag is for commenting. The string that follows will be appended to the end of the rsa public key. This helps when you copy the public key to the remote server — you’ll know it was copied because of the comment you provided.

The following is what you will typically see after you execute the previous line of code.

Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase): [enter something complex]
Enter same passphrase again: [confirm by entering it again]
Your public key has been saved in /Users/username/.ssh/id_rsa_userA.pub.
The key fingerprint is:
81:d4:12:cd:57:aa:42:47:12:de:4c:23:6a:34:62:78 userA @ somedomain.com
The key's random art image is:
+--[ RSA 2050]----+
|        ..+0.    |
|         .. .    |
|         *.*     |
|       +.o o     |
|     .. +        |
|      S.  ..     |
|        ..       |
|       o + . . . |
|        .  +o.oE+|
  • After generating the rsa key pair, you have the option of entering a passphrase. You should do this! Check out this GitHub article on that (http://goo.gl/rR1ebp)
  • The location of the public key is given.
  • The fingerprint and random art image is also generated.

Repeat the ssh-keygen command for the other connections. Be sure to keep the filename of the key file unique and the comment unique, as well as relevant to the connection.

Use ssh-copy-id to copy the public rsa key to the remote server. (Install via GitHub, MacPorts or Homebrew).

ssh-copy-id -i ~/.ssh/id_rsa_userA.pub userA@somedomain.com
  • The -i flag allows you to specify the public key to upload.
  • The last argument (userA@somedomain.com) is the remote host connection info.
  • ssh-copy-id will create the authorized_keys file if it doesn’t exist and append the public key (specified after the-i flag “~/.ssh/id_rsa_userA.pub"). It’ll also update various file and folder permissions.
  • You will be required to type in the account password to access the remote server (note: this is not the “passphrase” you created at the beginning of the tutorial)

Test the connection again by ssh command:

ssh userA@somedomain.com

Mac OS X will then ask for you to enter the “passphrase” you should have created when you used the ssh-keygen command. It is important to check the “Remember password in my keychain” box. By doing this, you eliminate from typing in the “passphrase” every time you login to this specific server.


This step is not necessary, but once connected to the remote server, you can examine the authorized_keys file:

cat ~/.ssh/authorized_keys
  • Within this file, you should be able to see the long key, followed by the comment included when the ssh-keygen command was executed.

You should log out and try another ssh connection to the same server. This time, the “passphrase” is saved by Keychain Access, so you shouldn’t have type it again. If all is well, you should be instantly connected to the remote server.

Repeat the public key transfer of all the remaining server connections.

Next is to store all the connection info into a config file contained within the .ssh folder. This will speed up connection to the remote servers by assigning shortcut names to each unique connection.

touch ~/.ssh/config
vim ~/.ssh/config
  • The file doesn’t exist, so I’m using touch command to create the file.
  • I’m using Vim to input the connection info.

For demonstration purposes, the following contains basic connection info for two different accounts. There is a lot that you can put into the config file, but I only limited it to basic connection info.

Host userA
  HostName somedomain.com
  User userA
  IdentityFile ~/.ssh/id_rsa_userA

Host userB
  HostName anotherdomain.com
  User userB
  IdentityFile ~/.ssh/id_rsa_userB
  • Host userA and Host userBis are used for pattern matching and applies the declarations that follow it (note the indentation of the lines that follow it). userA and Host userB are the names I choose for their unique connections. This will also be used when you remote connect to the server. It’s the shortcut name, so keep this name unique.
  • HostName somedomain.com and HostName anotherdomain.com states the domain of the remote servers.
  • User userA and User userB states the user account to the corresponding remote server.
  • IdentityFile ~/.ssh/id_rsa_userA and IdentityFile ~/.ssh/id_rsa_userB states the specific private rsa key.
  • More info about what can go inside the config file can be found here http://goo.gl/FEF1a5 or by checking out the manual pages in terminal (man ssh_config)

That’s pretty much it. You can then quickly connect to the remote server, without inputting any password by typing in the connection type (ssh, sftp, etc) followed by the shortcut name as listed in the config file — the one after “Host“. Here are some connection examples:

  • sftp userA
  • ssh userA
  • sftp userB
  • ssh userB
factory image errors

Android errors: archive does not contain ‘boot.sig’ & archive does not contain ‘recovery.sig’

I tried updating my Nexus 5 with the latest Lollipop 5.0.1 version. My phone is rooted, so I can’t use the OTA (over-the-air) updater. I attempted to use the same process that I used to update from Kit Kat (4.4.4) to Lollipop 5.0. I’ll recap the process:

  1. I downloaded the 5.0.1 factory image (hammerhead) from https://developers.google.com/android/nexus/images
  2. unpackaged the .tgz file
  3. executed the flash-all.sh program (note: I’m on a Mac)

During step three, I encountered a problem:

archive does not contain 'boot.sig'
archive does not contain 'recovery.sig'
fastboot(99706) malloc: *** mmap(size=1006034944) failed (error code=12)
*** error: can't allocate region
*** set a breakpoint in malloc_error_break to debug
failed to allocate 1005027540 bytes
error: update package missing system.img

I thought this was due to my phone being encrypted. I tried to troubleshoot, but I ended up soft-bricking my phone. I got myself up and running by flashing the Kit Kat 4.4.4 factory image. I also reverted back to the 5.0 Lollipop backup I made before attempting the update. I later figured out, this is not an encryption issue (I was able to update my encrypted Nexus 7 to Lollipop 5.0.1 using flash-all.sh program).

From a forum post on XDA (link here) suggested flashing the files within the image-XXX.zip individually (comment from manasgirdhar). I found another forum that clearly state the steps and flashing order of factory images. The steps are found here (drill down to “Method 2”). Quick recap of the process:

  1. expand the image-hammerhead-lrx22c.zip file
  2. flash the bootloader.img file
  3. flash the radio.img file
  4. flash the system.img file
  5. flash the userdata.img file
  6. flash the boot.img file
  7. erase the cache
  8. from the phone, boot into Android recovery
  9. from recovery, select “Wipe data/factory data reset”
  10. reboot

I got hung up on step 9. I held down the Volume Up + Power buttons too long and ended up rebooting to the system. The system won’t boot until you do the data wipe step. The trick is to push the Volume Up + Power buttons simultaneously or, push and hold Volume Up, then press the Power button, making sure not to hold the buttons down too long. If you get stuck in the boot animation, just boot back up into bootloader (hold down: Volume Up + Volume Down + Power), then continue with step 8.

As with any system mod you perform on your phone, you and only you are responsible for the outcome. So, please be very careful. If you do not understand how to flash a file from your computer to your Android phone, then you shouldn’t attempt to do any of the stuff I’ve posted here. I posted procedural steps not literal computer commands. Simply copying and pasting the steps into a command prompt will not work. If you decide to proceed with “Method 2”, please follow the procedure thoroughly as stated in the XDA forum post.

adb push & adb pull to transfer from Mac to Android device

Here’s a screencast of a tip/tutorial on how to transfer files or folders between an Android device and a Mac. There is a GUI utility called Android File Transfer that’s more intuitive. The only problem is that it sometimes fails [read: crashes] on transferring large files. I found adb technique to be consistent and fast.

I also used adb shell to establish a shell in the Android device. I would then locate the target file or the target directory. Once found, I would copy and paste the path to complete the command:

adb pull /pathOfFolder_onAndroidDevice/filename /pathToMacFolder
adb push /pathToMacFolder/filename /pathOfFolder_onAndroidDevice

Using a two terminal window allows me to copy the path onto the other terminal window containing the command. This saves from exiting the shell in order to type the command.

Wrapping earbuds

Coiling (or wrapping) earbuds seems to be a no-brainer. I used to wrap the earbud wires around my fingers in a circular coil. At the end of the wrap, I’d give a little slack and wrap that around the circular coil to keep the coil from unraveling.

There are two problems to this technique.

  1. There is a chance of becoming knotted when unwound
    • this can easily happen when one of the working ends gets fed into one of the circular coils
  2. The cinching of the circular coil can cause issues with the wires of the earbuds
    • the tight loops can cause the earbud wire to unwind like a pig’s tail (little curls where the tight loops were located)
    • damage to the internal wire causing one or both buds to stop working
    • the wires connected to the jack can become loose; again resulting in one or both buds failing

To tackle the first problem requires finding the right coiling method. Google search results showed the figure-8 coil to be effective and efficient. I’ve used this method for months. But I still secured the coiled earbuds with multiple tight loops and some half-hitches thrown in.

When wrapping the rubber band on itself for a single pass is called a lark’s head (cow hitch). Wrapping it an additional time is a prusik hitch (prusik knot).

I had to find another solution to locking/securing the fig-8 coil:

* This second video shows an updated way of applying the rubber band to the fig-8 coil:

QuantumFx Jumbo Universal Remote (REM-115)

I purchased this jumbo remote from eBay. There are various versions of this remote. The one I have is branded: QuantumFx REM-115.

The DVD device button was reset on accident. I couldn’t find the manual. I tried googling “Jumbo Universal Remote”, but the hits referenced a different maker. The unit looks similar, but the button configuration was not the same. The codes for the device online did not work for my remote.

With a little trial and error, I was able to activate the auto code search feature on the universal remote. Here’s a quick rundown on the steps in pairing a button preset to a device:

  1. Turn on the device you want to control (eg: the TV, DVD, VCR, etc.)
  2. Point the QuantumFx remote to the device, and press and hold the designated device button on the remote (either: DTC, TV, VCR, DVD, or SAT)
    • hold down the button until the LED light remains on
  3. Press the “Power” button to begin the auto code search
  4. When the device (from step 1) turns off, press the “Enter” button on the QuantumFx remote