Monday, November 11, 2013

Windows 7, GitLab, Git for Windows and SSH keys

It's been a while, but here's the latest "WTF WTH WHY IS THIS NOT DOCUMENTED!?!?!?" moment.

So you want to push to GitLab over SSH aye?  This should be simple right?  Follow these steps it took me a couple of hours to figure out, and it will be!

  1. I've assumed you've already installed Git for Windows and GitLab somewhere.
  2. cmd
  3. cd {Directory where you've installed Git for Windows}/bin
  4. ssh-keygen -t rsa
    1. When asked for the location to save to, type in ../.ssh/id_rsa
  5. Open {Directory where you've installed Git for Windows/.ssh/id_rsa.pub}
  6. Copy the contents and set this up as your public key in Gitlab.
  7. ssh git@gitlabserver.
    1. Type y and Enter to add to known hosts.
  8. Close your cmd window.
  9. Edit your environment variables.  If you want to use TortoiseGit you're officially f*cked. 
  10. If there's an environment variable to do with TortoiseGit, delete it.
  11. Edit the global PATH. 
  12. There will be a path that points to {Directory where you've installed Git for Windows/cmd}.  Change this to {Directory where you've installed Git for Windows/bin}.
  13. Just for kicks, copy your .ssh folder to {Drive where you installed Git for Windows}/.ssh and C:\Users\youruser\.ssh.
  14. Hey presto, it should now work!  Use cmd to do your git stuff.
Enjoy.

Saturday, June 16, 2012

Copying your Angry Birds progress from iPhone/iPad to Android

The title of this post says it all, I've worked on getting three stars for so long on my iPhone, there was no way I was starting again!!

This post comes with NO WARRANTY, GUARANTEES OR SUPPORT OF ANY KIND.  This probably works.

There were some tutorials on the interwebs for this, but I didn't find them very useful, or simple.  So, here's the easy version, for example, Angry Birds Space HD:


  1. Download and install the Android SDK:   http://dl.google.com/android/installer_r18-windows.exe
  2. Download and install iPhone Backup Extractor:  http://software-files-a.cnet.com/s/software/12/49/60/51/cnet2_iphonebackupextractor-latest_exe.exe?token=1339863816_3cf906d9686fb40aa95358d1aad7aaa6&lop=link&ptype=3001&ontid=18553&siteId=4&edId=3&spi=260644610ae5266567eca5edec7a9d35&pid=12496051&psid=75373326&isDlm=1&fileName=cnet2_iphonebackupextractor-latest_exe.exe
  3. Back up your iPhone using iTunes.
  4. Create a new folder called "C:\PhoneRestore"
  5. Run iPhone Backup Extractor.
  6. Click the "Expert Mode" button.
  7. Expand Application->com.rovio.AngryBirdsSpace->Documents
  8. Tick highscores.lua and settings.lua
  9. Click "Extract Selected"
  10. Rinse and repeat steps 6 through 9 for eaglepurchases.lua and episodepurchases.lua
  11. Run Start->All Programs->Android SDK Tools->Android SDK Mangager
  12. Install "Android SDK Platform-tools" under "Tools" and "Google USB Driver" under "Extras".
  13. Go to C:\Program Files (x86)\Android\android-sdk\extras\google\usb_driver, right hand click android_winusb.inf and click "Install"
  14. On your Android device, go to Settings->Developer options and tick "Android debugging".
  15. Make sure Angry Birds Space is closed on your Android device.
  16. Connect your Android device to your computer with its USB cable.
  17. Wait for Windows to say your device is ready to be used.
  18. Click on Start, and type "cmd" and press enter.
  19. Copy each line and paste into the cmd window:

cd "C:\Program Files (x86)\Android\android-sdk\platform-tools"
adb shell
cd /data/data/com.rovio.angrybirdsspaceHD/files

cp eaglepurchases.lua eaglepurchases.bak

cp episodepurchases.lua episodepurchases.bak

cp highscores.lua highscores.bak

cp settings.lua settings.bak
exit

adb push C:\PhoneRestore\Application\com.rovio.AngryBirdsSpace\Documents data/data/com.rovio.angrybirdsspaceHD/files
adb shell
cd /data/data/com.rovio.angrybirdsspaceHD/files
ls -al

At this point, you should see some files that have "app_x" e.g. "app_59" on the line.  Edit the next line to suit.

chown app_59 *
exit

DONE!!  Open Angry Birds Space HD on your Android Device.

Remember to turn the Android debugging back off.









Thursday, November 24, 2011

Cisco SCA BB API - TimestampController thread not exiting

Today I finally figured out why my programs written with the Cisco SCA BB API wouldn't close themselves. Their lovely programmers decided to start an orphan thread that never exits, and doesn't disappear when you call SCABB.logout!!

The solution:

1) Create a class that looks like this:

public class ShutdownTimestampController implements TimestampController
{
public void terminate()
{
//do nothing
}

public long getCurrentTimeStampInMilli()
{
return new Date().getTime();
}

public void setAccuracy(long l) throws IllegalArgumentException
{
//do nothing
}
}

When you're ready to shut down, call this:
Timestamp.setController(new ShutdownTimestampController());

Problem solved! This was quite painful to find, /angryRachel

Thursday, July 7, 2011

Installing Android Applications - Application Not Installed

OK so I wrote my first Android application today.

I was messing around installing it on a phone, and had this problem where the application had previously installed, but then I created a new signed package, and tried to overwrite and it kept on failing!!

It turns out, that unless the newer version of the application is signed by the same cert as the currently installed version, it will refuse to overwrite.

The solution when you're playing around in a dev environment is to simply delete the app before re-installing, and remember to always publish your apps using the same certificate as the last version!

Monday, May 16, 2011

Magento - what to do when someone deletes the root category

We all know users make errors. Even developers make errors. Last month, I had an extremely embarrassing mistake to admit to my boss - I'd deleted a live table. Thank goodness it wasn't something important.

Last week, someone deleted the Magento root category in a Magento install I provide services for.

It turns out this was easy to fix, but it took me a good hour to find!

So, the symptoms were:

  • No root category
  • No categories showing on the site
  • Couldn't create a new root
  • When I went to choose the root for the store in the config, the dropdown was blank!
  • The categories were still in the catalog_categories table.
So, the first step, is to find the store and check what the root category is. To do this, look at the core_store_group table. My root category was 2.

Now look at catalog_category_entity. Check the path of the root category (2 in this case).

Tada! All the categories had paths such as 1/2/3/42, whereas the #2 category had a path of "Default Category"!.

Changed the path to 1/2 and it fixed it.

All the forum posts I found at the Magento site were unhelpful, I've generally found the forums there to be mostly useless.


TCPDF and True Type Unicode Fonts

Ok, so todays aim was to fix a problem with embedded fonts in PDFs generated by TCPDF.

The symptoms were:
  • An error on my computer "Cannot extract the embedded font" when printing.
  • A customer got a strange error and couldn't print the PDF at all (I can't find the error message sorry).
  • When viewing on the iPhone, parts of the document were missing.
We'd created the font files by going straight from the font in C:\Windows\Fonts using the instructions at http://www.tcpdf.org/fonts.php (.ufm files), so for TTF Unicode.

The solution was:

  1. Install this: http://ttf2pt1.sourceforge.net/ in Ubuntu it's as easy as apt-get install ttf2pt1
  2. Copy the windows ttf files to the linux box, change the filenames to all lower case and no spaces.
  3. Go to the tcpdf/fonts/utils directory.
  4. Put your lower case ttf files here.
  5. Run ttf2pt1 yourfontfile.ttf
  6. php makefont.php yourfontfile.ttf yourfontfile.afm
  7. cp yourfontfile.php ..
  8. cp yourfontfile.z ..
  9. DONE!
This changes it to an ANSI ttf instead of a CID one. You can check out the fonts in the PDF document by opening a document and going File>Properties>Fonts. If you see the embedded fonts as anything other than True Type ansi, you've got a problem, try the steps again!

Now the files work perfectly on iPhone, and for printing. Problem solved.

The reason for this blog

Hi there!

I've created this blog to hopefully provide some pointers for using and configuring open source software. Throughout the years I've often spent hours trying to solve some issue, only to find that either:

  • The question has been asked before and not answered
  • The project doesn't have a very active user community
  • The documentation is non-existant.
  • I end up reading the source or going through some painful trial and error to solve the issue.
So, I've decided to share. I hope you find my posts useful, enjoy!