All posts in Development

Fix Homebrew – You have no /usr/bin/cc (Xcode)

I recently did a fresh install of OS X Lion on my Macbook Pro

I installed XCode, homebrew, and git.

After trying to install mysql via homebrew:

brew install mysql

I received this error:

Error: Failed executing: ./configure –prefix=/usr/local/Cellar/readline/6.2.2 –mandir=/usr/local/Cellar/readline/6.2.2/share/man –infodir=/usr/local/Cellar/readline/6.2.2/share/info –enable-multibyte
If `brew doctor’ does not help diagnose the issue, please report the bug:

https://github.com/mxcl/homebrew/wiki/checklist-before-filing-a-new-issue

So, I did what I was told, and ran:

brew doctor

This returned:

You have no /usr/bin/cc. This will cause numerous build issues. Please
reinstall Xcode.

But, Xcode is installed
After some googling (which if you’re reading this, you’ll notice there’s not a lot of results), I found the solution.

Xcode needs the Command line tools installed.

To do this, open Xcode, click the Xcode menu, and select preferences.
Click install next to Command line tools:

Review of nightmare with Elance provider (WebHouse)

I’ve used eLance for various outsourcing projects for a number of years.
(Great for small tasks, and an extra pair of hands until the 25th hour in a day is discovered!)

Sure, I’ve had my fair share of problems, however, all have been amicably resolved, talking with eLance and the contractor.

WebHouse
(Md. Zakir Hossain Dakua)

Recently, I had a small requirement for a WordPress theme to be slightly customised.
Unfortunately, I was heading off on holiday, so needed to outsource it, to meet my clients timescale.

I posted the job up on eLance, and had the usual 30 or so bids.

One of those, was from WebHouse (Zak D.), from Shabujbag, Dhaka, Bangladesh.
Real name – Md. Zakir Hossain Dakua.
Just in case you’ve had contact from him directly, his email address is:
zakirdaq@gmail.com

I’m usually pretty good at spotting the “bulls*t” in the initial communication (typically, they’ll just say “yes” to everything")

The fixed price work was completed, and he immediately began pressuring me to release the escrow.
He also changed the job to “complete” which meant escrow would auto-release.

Due to my holiday, I didn’t have chance to review the code, was just able to check the basic functionality.

Later, when more data had been added, it was apparent there was a problem with his code.
I asked to get him to fix his own bugs, and here is where the problems started.

A contractor can create a job on your behalf!

On eLance a contractor can create a paid hourly job on your behalf, without you authorising it!
This is what happened. I asked him repeatedly to tell me how long in hours, it would take (and therefore how much) Obviously I got no reply.

WebHouse offered no reply, until he submitted a time-sheet for over 7 hours (at $20/hour) to fix these bugs.

I rejected this, however, but, was on vacation when the “review period” deadline was.

I had emailed eLance to state that I do not authorise them to charge my card.
Heck, I even cancelled my credit card before I went!

However, eLance ignored all of this, and charged my card anyway (damn pre-authorisation must of kicked in!)

Since then, I’ve had nothing but bad news from eLance support who refuse to help.

But why should they? They get their 10% commission from the $150 odd I have been scammed by.
They claim that their “WorkView” process is bullet proof, and that I could review the screenshots… etc…
This is all true, but the work he was doing, was to fix bugs he had created, on work that had already been paid for!

WebHouse has been very unhelpful, right from the start of my dispute.
Stating that the work was done, it was quality work etc…
He even started getting rude, calling me “mad” for doubting the quality of his work (all in hard to decipher, broken English)

I’m using this blog post to drive home how poor his work really was!

I just hope a prospective client stumbles across this post, and choses to decline his bid, before being let down in a similar way to me!

Resolution

Elance finally agreed (after many emails) that there was a problem with the way WebHouse worked.
Although, unfortunately, they wouldn’t take the money back off him, they did credit me with $75.

So, moral of the story, I guess:
Don’t use eLance WorkView, or eLance at all for that matter!
I’ve since moved to oDesk. Far more reliable.

JoeBlogs wrapper moved to GitHub

Following from my plea for help for JoeBlogs I finally got round to learning Git.

The project has now been moved to GitHub:
http://www.github.com/alexjamesbrown/joeblogs

I will eventually move the Wiki / Docs to the page also.

If anyone would like to become a contributor, please contact me on GitHub

Create a Google Chrome Extension

I’ve been meaning to look into creating a Google Chrome extension for a while.

Earlier this week, I successfully RickRoll’d Rob Ashton on twitter, which in turn, after a RT, RickRoll’d several others. Many of whom replied with tweets like

@alexjamesbrown @RobAshton You bastards! ;-)

@alexjamesbrown @RobAshton Damn it! grrr.

So, that got me thinking.

What if there was a way to stop you being RickRoll’d. Then I remembered I wanted to learn how to create a Google Chrome Extension… The two ideas fused, and RickMeNot was born.

Step 1 – Create a Manifest File

I created a RickMeNot directory (and init a git repo, of course…)

Then, create a new file using <insert your favourite text editor here>

All  extensions, installable web apps and themes have a manifest file.
This is a JSON file, needs to be called, quite descriptively, manifest.json.

Read more on Manifest Files

The manifest.json for RickMeNot looks like this

{
  "name": "RickMeNot",
  "version": "0.1",
  "description": "Prevents you from being rickroll'd.",
  "background_page": "background.html",

  "permissions" : [
    "tabs"
  ],

  "icons" : {
    "48" : "icon-48.png",
    "128" : "icon-128.png"
  }
}

Most of this is fairly self explanatory.

What we’re basically doing, is setting the name, version and description of the extension.

We then specify the background_page.

A background page, is basically a long running script that manages a task in the background, while the extension is active.

This particular extension won’t need a fancy button (Browser Action) or anything like that, so we only need to specify our background page.

Permissions

One thing to take not of is the permissions array.

This particular extension needs to be able to access the urls of tabs etc… so, we’ll need permission to use “tabs”.

Background Page

Ok. So we have our manifest file that tells the extension what to do, so now we need to create a file that tells it how. This will be where the main functionality of this extension is.

Although this is a .html it doesn’t have to contain the usual doctype and other tags.

It simply needs a <script> and </script> tag, with all the script for the code in between.

Let’s start real simple:


<script>
    chrome.tabs.onUpdated.addListener(tab_updated);
</script>

What this does, is add an event handler for the tabs.onUpdated event.

As expected, this fires when a tab (any tab) is updated.

Note: I’ve called our callback tab_updated – this can of course be called anything.

Our tab_updated function looks like this:

function tab_updated(tabId, changeInfo, tab) {
    for (a in rickUrls) {
        if (tab.url == rickUrls[a]) {
            chrome.tabs.update(tab.id, { url: 'savedFromARickRoll.html' });
        }
    }
};

Ok- so what this does, is loop through all the values in our (as yet undefined) rickUrls and checks if the tab.url (the value from the passed in tab object) is equal to one of the values in our array.

If it does, it updates the tabs url (think of this as a redirect) to “savedFromARickRoll.html” (more on this later)

Populating our array using body onload

So, now we need to populate our rickUrls array.

While our background page doesn’t have to have HTML tags, it can. It can also contain some client side executed javascript.

In this instance, we’re most interested in executing the body onload event

In our background.html we simply add:

<body onload="init()">
</body>

Our “init” function is in between the <script> </script> tags and looks like:

function init() {

    rickUrls = new Array(
      "http://www.youtube.com/watch?v=oHg5SJYRHA0",
      "http://www.youtube.com/watch?v=EK2tWVj6lXw",
      "http://www.youtube.com/watch?v=XZ5TajZYW6Y"
      )
}

In version 0.1, we’re just hardcoding a few of the known youTube URL’s

In later versions, I’ll rewrite this to check an external file / service or something to get an up-to-date list of them.

Putting It All Together

This is what our background.html looks like:

<script>

    // Simple array containing the URLs of Rick Astley - Never Gonna Give You Up videos.
    // In this version, we're hard coding it, however later on, we'll make this dynamic
    var rickUrls = new Array();

    // Function that is called on the body onload event
    function init() {

        //fill our array with the URLs
        rickUrls = new Array(
		"http://www.youtube.com/watch?v=oHg5SJYRHA0",
		"http://www.youtube.com/watch?v=EK2tWVj6lXw",
		"http://www.youtube.com/watch?v=XZ5TajZYW6Y"
		)
    }

    // This function is called by the listener we added, when the url of a tab changes.
    function tab_updated(tabId, changeInfo, tab) {
        for (a in rickUrls) {
            if (tab.url == rickUrls[a]) {
                chrome.tabs.update(tab.id, { url: 'savedFromARickRoll.html' });
            }
        }
    };

    // Listen for any changes to the URL of any tab.
    chrome.tabs.onUpdated.addListener(tab_updated);

</script>

<body onload="init()">
</body>

Files within an Extension

An extension can contain files, like our savedFromARickRoll.html, and you can reference them locally.

This also applies to images (see the image in our savedFromARickRoll.htmlnoRickRoll.jpg)

You can’t however, refer to anything else on disk (c:\ or anything like that)

This is obviously for security reasons.

Source

I’ve put all the source for this post on GitHub

You can download it here: https://github.com/alexjamesbrown/RickMeNot

What’s next…

I’ve got a couple of follow up posts planned on this.

Firslty, a short one on how to list your extension in the Google Apps Marketplace (will add link as soon as it’s ready)

Also, when I get time, I’ll write a post along the lines of calling external services to get a list of updated Rick URLs

Excluding ID field doesn’t work with FindAndModify

While playing with incremental IDs with Mongo DB the other day, I stumbled across a bug in mongodb.

Consider the following command:

db.sequence.findAndModify({
     query: {"_id": "customer"},
     update : {$inc : {"seq":1}},
     fields:{"_id":0},
     upsert:true,
     new:true})

Notice the fields:{"_id":0}, part (highlighted)

According to the documentation, this should prevent the id from being returned, however when I try and execute this command, I get this error:

Uncaught exception: findAndModifyFailed failed: "exception: assertion c:\\builds\laves\\mongo\\windows_64bit_v1.6\\mongo\\db\\../bson/bsonbjbuilder.h:115"

image

I opened a ticket with their issue tracking system (Jira)

After a day or so, I had a response that this was caused by a limitation to how FindAndModify was implemented.

Luckily, they’re planning on re-implementing this feature (see this ticket) which should remove this restriction.

In the meantime, the method of auto-incrementing ID’s described in my previous post will still work, but it will return the _id as well.

In a future release of mongodb, we’ll be able to strip this out, and make it even speedier!