Solving "sh: mysql: command not found" In MAMP Pro 2 and MAMP Pro 3

If you are reading this there is a possibility you have run into this error message in your terminal window: sh: mysql: command not found

This error is being displayed because MAMP Pro stores MySQL in a location on your Mac that isn’t added to your main $PATH. MySQL is stored in the MAMP Pro bin folder here: /Applications/MAMP/Library/bin/mysql

Fortunately the fix is rather simple following the below steps:

  • In your home directory create or edit the file “.bash_profile” you can access your home directory by typing: cd ~/
  • Add this to the top of the file: export PATH=$PATH:/Applications/MAMP/Library/bin
  • Save the file and then restart your Terminal
  • In your newly restarted Terminal window type: mysql –version

This will now map MySQL to your path and allow you to access it by just typing “mysql”

Adding Location Based Search To Your Website/Application Using Google Places Autosuggest

If you have used Airbnb before, then you would be familiar with the location field where you type your desired location and it gives you a dropdown of suggested places based on what you type.

I have seen sites that try and build their own location databases, but we all know it can be a difficult and sometimes expensive task to obtain up-to-date global location information for cities, landmarks, postal codes, regions and more. The Place Autocomplete API gives you the power of the Google Maps search dropdown without needing to buy the data.

The field isn’t only just limited to getting global addresses and locations, it also allows you to enforce restrictions on countries, cities and localised areas. You can also obtain every single component of the address selected from the field as well. You can specify a search radius, display results based on the users current location and more.

Surprisingly, there are a lot of developers out there rolling their own locations functionality into their web applications, when Google gives you a powerful API and comprehensive database for free. So stop building your own solutions and use the Place Autosuggest API here.

The Expendables 3 Movie Piracy Conspiracy Plot

Recently Variety posted an article titled Expendables 3 Flops: Is Piracy To Blame? in which a case is made whether or not the movie leaking onto torrent sites 3 weeks before its official release damaged it at the box office.

The movie fell short $10 million of its expected $26 million, debuting at $16.2 million in revenue which is atrocious when you compare that to other movies that debuted at the same time as it did like Teenage Mutant Ninja Turtles and Lets Be Cops.

Deliberate

I am stating the case that this was a deliberate leak from the studio themselves. A movie leaking its own movie weeks out from its release? Crazy, right? Well, not if you think about it logically.

Movie piracy is at an all time high and studios don’t know what to do. They’ve tried lobbying for three strikes policies, ISP level filtering and taking down the torrent sites themselves to no avail for years now.

The issue is while studios will have you believe that the industry is shrinking and dying, the good movies are still making great profits.

Here are some movies released in the last couple of years that have ranked amongst the most profitable movies of all time.

Rank #13 – Transformers: Age of Extinction (2014) at $1,054,437,000
Rank #5 – Frozen (2013) at $1,274,219,009
Rank #6 – Iron Man 3 (2013) at $1,215,439,994
Rank #22 – Despicable Me 2 at $970,761,885

It might surprise you to know that not one single movie in the Expendables series has ranked even last on the highest grossing movies. The maximum amount this series has made is $34.8 million for the first movie, which while not completely horrible, still wasn’t that great.

Does that tell you something? It tells you this franchise is dead in the water and people have stopped caring. The fact the third movie was made for PG 13 audiences and up when the two previous films were R rated tells you something else as well. Young teens would prefer to see Guardians Of The Galaxy over a film comprised of dads favourite action stars from the 80′s and 90′s.

Is piracy sort of to blame?

You can’t rule out the fact a movie leaking almost a month before its debut and being downloaded by 2.2 million people would not have at least some effect, but I think the effect the leak had is being greatly exaggerated.

In 2009 the film X-Men Origins: Wolverine leaked before its release (albeit a unfinished cut, but still the full movie) and it went on to gross over $373 million at the Box Office, the movie had a budget of $150 million. Even though this particular X-Men movie received pretty bad reviews, it still went on to make a lot of money.

The Scapegoat

Why would a studio leak its own movie that they sort of probably knew was going to flop? They needed a scapegoat. The leak and discussion around lost revenue comes at a time when the entertainment industry is at a stalemate. They’ve tried lobbying for three strikes policies, they’ve tried getting the ISP’s to shoulder the blame and police users and they’ve tried suing infringers to no avail.

You can’t deny the paltry figure The Expendables 3 made at the Box Office looks pretty bad on paper, especially when your movie leaked almost one month prior, it makes for a pretty strong case that piracy was the reason when the sane of us know it wasn’t the contributing factor.

What better way to get people on your side and to try and turn the tide in the copyright/piracy debate than to present some harsh numbers that work in your favour?

You could call it a false flag attack on the entertainment industry. However, it’s just a theory and logical arguments like why would a studio fund a movie that they knew would flop and cost them lots of money and damage their reputation?

My Soundwave Festival 2015 Wishlist

The now massive and widely successful Australian music festival for rock, punk and metal genres is back in 2015 with a new two day festival format. This is due to complaints from prior years with timetable conflicts, disagreements with larger bands wanting headline spots and overrall the standard festival issues that arise.

Personally I am really excited about the rumoured bands for the festival. My ideal line-up would contain most of, some or best case scenario all of the following bands. Following the traditional Soundwave formular we can expect to see a lot of bands that made an appearance and didn’t piss AJ Maddah off making an appearance at Soundwave Festival 2015. Some of the bands on my wishlist played Soundwave Festival 2012, so there is a good chance some of these bands will be there.

Thrice

This is a 1000:1 shot since the guys are currently on a hiatus, but if AJ could pull some strings to get the guys to play one last Australian show (the band never made it out here for a farewell tour) my dreams would be realised. We sadly didn’t get to hear Major/Minor material live, bring the band back for one last Soundwave performance. I would pay double the ticket price to see Thrice added to the lineup, I would cream my pants if they were not only added, but also headlined.

He Is Legend

I think He Is Legend would be a perfect fit for Soundwave. They’ve just released a new album, they haven’t toured Australia in a very long time and they are absolutely brilliant live.

Slipknot

There is a strong rumour that Slipknot is going to be one of the headlining bands of Soundwave Festival 2015. In-fact, AJ has openly stated the band can play any time they want, every year if they wanted too. The guys are gearing up for a new album release and the timing would fit in with Soundwave really well. The $180 cost of a ticket for two days of Soundwave would be worth seeing Slipknot alone.

The guys played Soundwave 2012, further propelling the rumour even further that this is a possibility.

Parkway Drive

Even though Parkway Drive can headline their own tours, now that Big Day Out is gone, Soundwave is the premier festival for these types of acts. AJ has openly stated they are always welcome to play, so if they agree, they would be an excellent addition.

Volumes

These guys are absolutely blowing up right now. Progressive metallers Volumes just released a new album and have been doing the rounds of some US/UK festivals. From what I have seen, they put on a great live show.

Every Time I Die

Supposedly it is all but confirmed these guys will be making their Soundwave Festival debut in 2015. ETID coupled with the addition of He Is Legend would make me froth at the mouth in excitement. The band toured for Soundwave Touring last year, so this all but confirms they’ll be making an appearance.

Deftones

The last time the band played Soundwave was its debut in 2007. What a great year, getting to see Thrice and Deftones perform was an amazing treat (right after one another). Since then obviously losing Chi was a big deal for the guys, they are planning on releasing a new album in 2015 and would be a great addition to headline again.

Rise Against

There is a VERY strong possibility the guys will be playing Soundwave 2015. Apparently they’ve openly stated they’ll be here in February/March 2015 to tour, all but confirming we get to see them either way. These guys are a class act and always a treat to see live. And surprisingly, this would mark the bands first Soundwave appearance.

Job For A Cowboy

A band of great guys making great music. Always put on a great live show and apparently all but confirmed to play Soundwave 2015. Hopefully this is the case.

Falling In Reverse

Even though front-man Ronnie can be a douche, you can’t deny FIR are a great band. If anything, I would see these guys (permitting there are no conflicts) just to see Jackie Vincent shred it up in person. The only possible thing stopping this happening is if Ronnie runs into Visa issues like he has in the past trying to enter Australia. If they’ll let Snoop Dogg in, surely they’ll let Ronnie in.

The Plot In You

I really enjoy the music these guys out. They’ve never played the festival and are currently gearing up to release a new album late 2014/early 2015. The timing would line-up perfectly with the schedule fo the festival.

Like Moths to Flames

Another potential band for Soundwave I would love to see added to the line-up. They released an album in July 2013, I am a fan of this bands music and think they would put on a great live show.

Should Cyclists Have To Pay Compulsory Registration?

There are a very few words in the English that can incite rage at the sound of them like the word “cyclist” can, especially in Australia.

The topic of “whether cyclists should pay registration” in Australia has been brought up quite a few times by some people, but is it a good idea?

Misunderstanding

When cyclists hear the words “compulsory registration” you can literally hear the veins in the heads of lycra laden cyclists popping out from their foreheads.

A registration scheme would not be expensive and it would not apply to everyone. If you’re not a road cyclist, but rather riding a mountain bike or BMX, you should not pay a registration fee.

The misconception in this argument is all forms of cyclist would pay a registration fee. Only a road cyclist would pay a registration fee and that would easily be determined by whether or not a cyclist is riding a road bike.

Little Timmy who rides his BMX to school wouldn’t have to pay anything, neither would a family riding mountain bikes through the park on the weekend. Registration would be limited to road bike users only.

Cost

Why should a cyclist who opts to ride on the road not have to pay anything? They’re contributing to the traffic albeit rather softly, they are using roads everyone else pays for through taxes and vehicle registration.

Even if the fee was only $80 a year, that’s nothing. You often see road cyclists at cafes happy to pay $5 for a large flat white, but complain when the prospect of paying registration is raised. Take into account that a road bike can costs thousands of dollars and requires maintenance which can get pricey as well.

If you can afford and expensive road bike, expensive coffee and expensive lycra outfit, why can’t you afford registration? A decent and brand new road bike can cost more than a second hand car to purchase outright…

Registration would also be considerably cheaper if you are already paying vehicle insurance. A cyclist would only pay the full amount if they don’t have any other registered vehicle or motorbike, taking into account registration would already be extremely cheap ($20 per month maximum ideally).

Why

The question of why is often raised as well. Cyclists smugly like to raise the point they’re helping the environment by riding and easing congestion as well, they’re doing road users a service by riding instead of driving.

And you know what, cyclists are right. One less car on the roads is not a bad thing for both congestion and the environment, especially if you can forgo the fact the bike they are riding was built in a factory producing greenhouse gases and was transported by truck from the factory to the store and possibly by plane if coming from overseas.

The reason for registration in my mind isn’t about raising revenue or covering up some kind of anti car registration loophole, it’s about safety and improvement.

Some benefits of registration would:

  • Cyclists caught breaking the law like riding through red lights, failing to stop at intersections or stop signs would be identifiable and fined. In most countries including Australia a cyclist has to abide by the road rules like a motorist.
  • Money could be used to fund new bike paths and bikeways as well as the addition of bike lanes on major roads and blackspots. Currently cyclists are getting riding infrastructure for free without paying a cent (except taxes).
  • A big benefit would be cyclists would stop selectively riding on the road and footpath whenever they feel like it (unless absolutely essential).

Wrapping Items Every X Iterations in PHP (without using counters or the modulus operator)

Recently whilst working on the reskin of a mammoth web application written in PHP, I encountered a scenario where I needed to wrap elements within a div every four iterations.

The task is simple enough and if you’ve worked with WordPress before especially, you’ll know the aged-old approach is to use a counter and then the modulus operator.

While the modulus and counter approach does work, it is hacky, complicated and messy. You’re probably wondering if there is a better way and there this.

Say hello to “array_chunk”

The array_chunk method in PHP is a very underrated function. It does what it says on the tin, it splits arrays into chunks. If an array has 40 items in it and we want to split it up into smaller chunks of say 10, we would have four arrays within an array adding up to 40.

Surprisingly, when I tell people about my use of array_chunk (which I’ve been using for a very long time) they are surprised and impressed. Most developers out there are still using the modulus operator like it is their only choice, this is why I have decided to write a blog post to make more people aware of array_chunk.

Wrap every four elements in a DIV (or any number)

<?php

	foreach (array_chunk($items, 4, TRUE) AS $chunks) {

		echo '<div class="wrapper">';

			foreach ($chunks AS $item) {
				echo '<div class="item">';
					echo '<h2>'.$item->name.'</h2>';
				echo '</div>';
			}

		echo '</div>';

	}

?>

Dear Misinformed: Please Stop Trying To Replace MySQL With NoSQL For Everything

Since NoSQL databases like MongoDB hit the mainstream scene a few years ago, it’s not uncommon to come across numerous Stackoverflow and Quora posts from people asking if or how they should replace a MySQL database with X NoSQL database.

The reality of the situation is you should only make such decisions based on your needs. Blindly picking a database without first assessing whether or not you need too or if it’ll even fit your use-case is a dangerous position to find yourself in.

MySQL can easily scale

A constantly recurring myth that keeps on being perpetuated is that MySQL can’t be scaled and doesn’t work well for fast writes. This is false, MySQL is a battle tested database that can perform any task if in the hands of a skilled database architect/engineer to handle writes and reads at an acceptable rate.

This post from 2011 on Highscalability.com reveals Newrelic were collecting 20+ billion metrics per day using MySQL as their database of choice.

Arguably Newrelic was much smaller back then in 2011 and is probably storing twice the amount of metrics per day, but it does highlight one important thing: MySQL in the hands of the right team can be scaled even to handle billions of rows.

MySQL is reliable and mature

Just because MySQL has been around for a long time now and is older compared to the newer hip databases ,doesn’t mean it has dated. In environments where storing critical data is crucial to your business, taking your chances on MySQL is going to be a safer bet than choosing a NoSQL solution that is only a few years old. MySQL is a battle tested database that has proven its worth.

Most shortcomings within MySQL are known and have workarounds, I am not saying MySQL is perfect, but it does fit most cases and hasn’t really been superseded or replaced by the newer databases that have come out in the last few years.

NoSQL != Relational

There is one thing that NoSQL databases aka document databases should not be used for and that is relational data. Although you can make the likes of MongoDB work with relational data, it’s not meant for the task.

NoSQL databases are meant to be used for data that is constantly changing and cannot be defined within a schema. This is why they are called document databases because they’re undeniably great at storing document like data which is constantly changing and no two results have to be the same.

Conclusion

Don’t believe the hype. MySQL still has a place, even in 2014 and NoSQL has its place as well, but isn’t a drop-in replacement for MySQL or any other database unless you’re working with data that would suit a NoSQL database instead of MySQL.

The Real Reason Tony Abbott & George Brandis Want To Capture Log Metadata

I’ll give you a hint: it is not to catch terrorists or prevent terrorist organisations communicating and plotting terrorist acts in Australia.

As Tony Abbott pointed out himself Australia’s threat level remains unchanged. The US already knowingly collects metadata via its PRISM program and considering most Australian traffic would be accessing US based websites it does not leave many possible explanations for such a scheme.

What is metadata?

Essentially metadata is data about data. Website owners use meta tags for page descriptions, a page title, author tags and more. Essentially it describes the content when read outside of the context of the data it is describing. It’s a higher level description of data.

In the case of accessing a website the metadata Abbott would want to collect would be the url of the accessed site, when you accessed it (time and date), the location you accessed it from, your IP address (your internet licence plate) and your internet service provider (ISP).

In the case of other activity, your phone calls would be logged although presumably not listened too. Only who you called and how long you spoke would be logged. Presumably text messages would fall into this category as well (with exception supposedly of the contents).

Attorney-General George Brandis used the analogy of, “They’re only looking on the outside of the envelope, not what’s inside of it”

A door

The metadata collection policy is a door to a wider agenda. In the greater scheme of things, because of the shortcomings and limitations of metadata, once the policy has been approved (if it is approved) it will open the door to amendments and additions.

One potential amendment a metadata collection scheme could include is George Brandis’ three strikes filter policy. A filtering and three strikes program would go hand-in-hand with a metadata collection scheme as they would have the information on what users are accessing, from where and give the user a warning as well as potentially passing on that information to rights holders.

It isn’t a secret that Brandis is in favour of protecting the rights of the entertainment industry and lacks the technical knowledge to fully understand the implications and complexities of integrating such schemes at an ISP level.

It is considerably easier to make amendments to a policy like this once it has been passed. In-fact, any amendment to a metadata collection policy could be done in secret under the guise of national security.

Faked

One thing the government doesn’t seem to acknowledge is that metadata can be faked. For $5 a month you can route your traffic through an offshore encrypted VPN tunnel thus circumventing the government’s plans to capture web metadata from some Australian users.

If the data is merely descriptive and not overly trustworthy or useful, it makes you question by Abbott and Brandis are pushing for such a scheme so hard. All but lending even more credibility to the idea of there being a bigger picture here Australians are not being told (like the hidden three strikes agenda).

Make your voice heard

There is no reason for metadata to be collected so widely like this schema would allow. While the uninformed might not have an understanding of what this proposed scheme is, it is undoubtedly a trick on the Australian public to pass more strict policies further on down the road.

Let your local members know you don’t agree with this policy, email your state representatives and send Abbott and Brandis a message this kind of policy will never be accepted by the Australian public.

Node.js + MongoDB = The Internet of Things (IoT)

Move over web 2.0, AJAX, flat design and NoSQL, there is a new buzzword in town that goes by the name of The Internet of Things or as it is commonly known on every tech blog as: IoT.

Wait, what is The Internet of Things?

The Internet of Things is essentially buzzword speak for devices and switches that can talk to each other without human intervention. Smart sensors and applications that share data with each other automatically, states are shared and data is used to determine actions and outcomes. Anything with a switch will eventually be connected, it does pose some security concerns, but that is for another time.

Some examples of The Internet of Things:

  • It’s cold outside and you’re almost home. Your car tells your home you’re almost there (based off of your GPS coordinates) and turns the heating on so the house is nice and warm for your arrival.
  • Your alarm clock screams at you to wake up. It tells your coffee machine you’re awake and starts heating up some coffee for you.
  • You are stuck in traffic, your phone already knows you have a meeting pencilled in your calendar and sends an email notifying the other person you are late and your approximate arrival time. It will recalculate your route for the most non-trafficked efficient route to your destination.
  • Your office printer knows it is running low on ink and automatically orders more (this is already a thing, but a perfect example of IoT)

With all of this data being captured and processed, it means an industry standard for this type of thing will emerge or already has emerged. The Internet of Things isn’t even a new premise, devices that are connected and share state have been a thing for a while now, it’s only new applications IoT is finding itself being applied to and albeit rather more advanced applications.

The Takeover: Part 1

As the trend of Internet of Things kicks off into top gear, there is one technology poised to take centre stage: Node.js.

Because of Nodes simplistic nature and how easy it is to build API’s with it (IoT is based on the premise of API’s), we already seeing Node being picked as the defacto choice.

Not only is Node great at being used as an API endpoint, it also scales very nicely even on economy hardware because it has less overhead than other server side languages competing in the same space. This means it is more cost-effective and because you write applications in Javascript it means the front-end and back-end share a universal language lowering the barrier to entry.

The Takeover: Part 2

There is also another piece of technology poised to take sidekick status: MongoDB. This NoSQL database by 10gen has one of the best marketing teams behind it. There is a good chance you have a MongoDB mug or know of someone who does.

It has infiltrated the enterprise already and it is often the defacto choice for most people looking for a NoSQL database. There are alternatives that are more free, but the paid support makes MongoDB an often picked choice by a lot of companies.

Node and Mongo work extremely well together and will be at the forefront of The Internet of Things trend movement for some time to come.

The Australian Start-up Scene: Begging For Holes In The Plastic

The thick plastic sheet currently encasing most Australian start-ups is begging to be pricked with a venture capitalists fork. It’s not secret that investment in the Australian start-up scene is very small, there are a few incubators in 2014 with more on the way, but relatively tiny amounts of capital with unfair terms.

Recently Australia was ranked 13th in Bloomberg’s Global Innovation Index which is a pretty stellar achievement for a country as small as ours.

Australia has always been at the forefront of innovation, rolling up your sleeves and getting things done without any help except from friends and family. Sadly in the tech space, times have changed and you can only get so far before you need some capital to go any further.

Not everyone has struggled of course, some known Australian start-up successes include:

  • Atlassian
  • Big Commerce
  • Campaign Monitor
  • Canva
  • Envato
  • Redbubble
  • 99Designs
  • GoCatch
  • Parkhound

For all of the successes that the Australian market has shared, many struggle to get fair funding or a chance. The general consensus within the Australian startup community is to build a MVP, save your pennies and book a flight to San Francisco to have a shot at making it.

There certainly is no shortage of co-working spaces or incubators, in-fact, in many aspects the Australian start-up scene keeps on getting stronger despite the lack of funding. The Australian government needs to do more to prevent great startups leaving the country for San Francisco due to our archaic tax laws and lack of incentives.

There are definitely parallels to the Australian music scene being witnessed, we’ve had some well-known acts like the Bee Gee’s, ACDC and INXS, but most people fly under the radar.

It’s just going to take some time before the likes of Y Combinator come to Australia and start realising there is a relatively untapped diamond mind here in Australia of talent.

We are just waiting for the right person(s) to come along and pierce some holes in the plastic covering the scene to finally expose the greatness within.