Remove dropbox conflicted files on Mac or Linux using Terminal

I like Dropbox. I use it all the time to share files across machines and work on group projects. However, I don’t like how Dropbox duplicates files as and saves them as conflicted copies. It’s not something that I need or use. I just delete those “conflicted” files. 99.99% of the time the conflicted files are not conflicted, Dropbox is just over zealous. Also I use .git to handle my file pushes so I know right away if files have changed. I don’t need Dropbox doing this for me.

I work on a Mac so here is something I run in my terminal to quickly remove those annoying conflicted files.

$ cd dropbox
$ find . -type f -name "* conflicted *" -exec rm -f {} \;

Increase PHP Script Execution Time Limit Using ini_set()

Today I had to set the PHP script execution time directly from within the php file. Here’s what I did.

Add the following code to your file. You can change the seconds to what you need. It is important to be careful using this on a live server. If you allow a script to run too long you could hog all your servers resources and bog the site way down. 5 minutes is a lifetime in server time and it might be longer than you need.

ini_set('max_execution_time', 300); //300 seconds = 5 minutes
On Business

Life lesson #2: Passion is not a luxury.

Steve Jobs quote

My first post for this blog was about inspiration and why I believed it was necessary for success in business. The other day I was watching some videos of Steve Jobs on You Tube talking about business success. In the interview he stated that passion was the ingredient that sustained successful people until they had success.

Achieving success is hard. Ask anyone who has played sport competitively, or tried to change the minds of people in a team or politics. It takes a lot of work and a lot of perseverance, and often times, in business it seems like it takes more perseverance simply because the goal is new and untried.

So passion is not a luxury anymore if you are an entrepreneur and you want to succeed. I’ve often believed that its good to love what you do, but haven’t really taken much time to think about the implications of loving what you do. It means that when the hurdles and challenges come, you have more than will-power motivating you to continue. It means that when your big sale fell through and you can’t pay yourself for a second time in two months you have more than will-power motivating you to continue. It means that when you can’t see the crest of the hill but believe in what you are doing you have more than will-power motivating you to continue.

“I’m convinced that about half of what separates the successful entrepreneurs from the non-successful ones is pure perseverance.” Steve Jobs

I don’t know what challenges you might be facing in your business, but I hope that you will persevere. If anyone is reading this and has a story about perseverance please leave it in the comments below. I would love to hear it. 

If you are interested, here are some great Steve Jobs quotes.


What to do when you have the error “too many connections”

Recently our servers went down. The error we were getting was “Too many connections”. This meant that we needed to increase the limit on the number of available connections within our mysql config file. The setting is called


Before you go upping the number of max user connections there are two things to consider.

1. Is your code opening and closing the connections efficiently?

According to the mysql “using mysql_close() isn’t usually necessary, as non-persistent open links are automatically closed at the end of the script’s execution.” However, there are rare occasions where the connections do not close properly, so it is always a good rule of thumb to include mysql_close() at the end of your scripts.

Another mistake that can occur is that you may be unintentionally opening a new connection for each query, rather than opening one connection and then closing it once all your queries are completed. This will definitely increase the number of user connections.

Also, using persistent connections are generally frowned upon these days. For php using mysql_connect has actually proven to be more efficient.

2. Do you have enough memory (RAM) available to handle your increased connections.

Once you know your code is clean and you are still running out of available user connections the next step will be to increase your number of max_connections on your mysql config file.

It is important to calculate your available memory before upping your connection limit however, other wise you will encounter this error:

Connect Error (1135) Can't create a new thread (errno 12); if you are not out of available memory, you can consult the manual for a possible OS-dependent bug

This error is simply telling you that you are using too much memory. To avoid this error when upping your connection number use the following formula to calculate your number of available connections.

Key_buffer_size + ((read_buffer_size + sort_buffer_size)*max_connections) = memory needed

If you know your server’s ram, calculating the number of max_connections is straight forward.

I hope this helps you if you are encountering this problem

Note: Your current settings for Key_buffer_size, read_buffer_size, sort_buffer_size and max_connections can all be found in your mysql config file. 


3 things I wish I had known before moving to Media Temple

Recently we migrated our server to Media Temple’s grid servers. I had heard good things about Media Temple from others before making the decision to migrate, however while migrating we started to encounter challenges that I was not forewarned about. So here are 3 things that I wish we had known before moving, I hope they will help you avoid the pitfalls we encountered.

Media temple gridserver

1. Mysql Views are not allowed

We discovered this while attempting to install our database on our new MediaTemple database. I sent a support request about this, they replied that they are planning on allowing views in the future, but don’t presently. While most web applications do not use Mysql views ours did. As a result I spent needless hours rewriting code to work without views. It was frustrating to say the least.

2. Maximum 500 emails per hour and 60/min

Here’s another small fact to know before deciding to move over to the grid server. There is a limit of 500 emails per hour. 500 emails an hour sounds like plenty. It’s not. Our application communicates to our users via email, sending updates and notifications constantly. We now pay for a 3rd-party API to send emails to our users. This is unnecessary and MediaTemple should really look at changing this.

3. No static outbound IP Address

This proved to be the biggest frustration of them all, especially because I asked one of MediaTemple’s support people about this before migrating and they ensured me that they had offered static outbound IP addresses. They do not. MediaTemple will give you a static IP address for all incoming requests. However, it will not give you a static IP address for outgoing requests. This was a big deal for us because we were using a secure API that required a single static outgoing IP Address. However, MediaTemple was unable to provide us with one. When I asked if they would be able to NAT the outgoing IP Address range to one address, the response was “Uhhhhhh?? Let me ask our server team”. Not very reassuring. They eventually responded with “no”, but without any reason why. We did come up with a work-around solution, but it is not ideal to say the least.

Despite these unpleasant surprises there are definitely some strong pros to MediaTemple. Its grid server uses a very eloquent node sharing system. This allows server resources to be freed up and reallocated where needed. Also they offer mysql containers to ensure dedicated ram is always available for your database requests for an additional fee. There support isn’t the greatest especially when compared to some of the hosting companies I also use, like LiquidWeb.

Overall I would recommend MediaTemple’s Grid Server, just know what you are getting into.


MVC architecture explained briefly.

Inevitably every programmer is going to encounter MVC architecture. MVC or model-view-controller is a pattern used by applications that divides the application into 3 parts. At first glance MVC can look more complicated than it is. Let’s look at the three parts.

Model – The model handles the data and cares about where the data is coming from. Typically it involves connecting to a database, but it could collect data by reading a file. The model only knows that data is there, it does not know what the data is or what you are doing with it.

View – The view cares about how to display the data. It doesn’t care where the data comes from or what the data means only that it is to display it.

Controller –  The controller is the bridge between the Model and View it interprets the data and handles any calculations. It doesn’t care how the data is stored or how to display it. It does care what the data means.

The advantage of MVC is that you can change things in one part of the application without “breaking” the other parts. For example, you could change where the data comes from in the Model. Because the View and the Controller never knew where the data came from they are not effected by the change. Likewise, you could change how you want the data displayed in the View but neither the Model or the Controller is effected.

For example. Let say we are viewing Facebook. What you see is the view. When loading a FaceBook page the view tells the controller that it needs data, the controller gets the correct data from the Model and sends it back to the View. The View then displays that data. The Model and the Controller don’t care that the data is being displayed on a computer or on an iPhone application.

So it’s really not a very complicated architecture structure.


Tutorial: How to add Google Analytics to WordPress

Step 1. Sign up for Google Analytics

Sign up for Google AnalyticsStep 2. Add a New Account

Once you are logged into Google Analytics:

Create New Analytics Account

    1. Click + New Account.
    2. On the Create New Accountpage, under General Information, enter your account name and the URL for your web property. You may see that the Account Name field has a default value of the URL for your web property. You can change that value to something more meaningful.
    3. Under Data Sharing Settings, select the data-sharing options you want.
    4. Under User Agreement, select your country or territory from the menu, read the terms of service, then select the check box for Yes, I agree to the above terms and conditions
    5. Click Create Account.

Step 3. After creating your account you will see your tracking code. Copy your analytics code for later use.

Google Analytics tracking code


Step 4. Add code to WordPress

I will be using the functions method.

      1. Login to your WordPress admin.
      2. Expand the Appearance tab and click Editor on the menu.
  • In the Edit Themes page you will see a list of files on your right. Click functions.php
  • Now on the top of the functions.php file below the comments add this code. Remember to paste your Google Analytics code from Step 3 here.
add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
	// Paste your Google Analytics code from Step 3 here
<? }

Now you have installed Google Analytics to your WordPress site. It takes 24 hours for Google Analytics to start showing your results. Log into your Google Analytics account in the next couple of days and you will see your traffic stats.


Tutorial: Force text to line wrap using CSS

Here is a problem I face occasionally. When displaying a long line of code, like the full URL of a link, the text can be wider than the containing div and instead of wrapping the text goes beyond the edges of its containing div which looks ugly.


Solve this by simply adding the following CSS property to your div’s CSS style

.wordWrap { word-wrap: break-word; }

Now the text will wrap nicely within your div container.



TinyMCE with image uploader TinyBrowser download

Download the full package of TinyMCE with everything needed here.

Previously I have used CKeditor for web applications and content management systems that I build. However, I became frustrated with how heavy CKeditor is. So I decided to give TinyMCE a try. Within an hour I realized that I loved it. However, it has two major downfalls. One it is very ugly. Two It does not come with a built in image browser and uploader.

Thanks to the hard work of others, both of these problems have been solved nicely. I did some research online and came across an article by thebigreason where he has kindly created a nice looking skin and is offering it for free.

Original Skin, Ugly and Busy
Clean Skin

Then I needed an image browser and uploader. TinyMCE does not include one in their download, but would prefer that users pay for it. That is fine, but I checked around online to see if any free plugins were available. I came across a great review of all the available free image management plugins for TinyMCE by Tysen. After first reading about them, I decided to test a few out myself, and quickly came to the conclusion that I prefered TinyBrowser. It seems to integrate the best into TinyMCE, is very easy to implement and has a nice user interface.

To use TinyBrowser and Thebigreason Skin simply copy the code below. I have included a working demo in the examples/ folder within the TinyMCE download.

Download the full package of TinyMCE with everything needed here.

If people are interested I will create a short tutorial on how to install TinyMCE and set TinyBrowser up.

On Business

Life lesson #1: What do you need to do to succeed in business? You need to be inspired.

I wrote this article a couple years ago and thought it was worth posting as my first post on this blog because I still find this very relevant to my success in business.

Not that long ago I learnt an important lesson: know what inspires you. With regards to business there are a lot of books on the topic of motivation, but not too many on inspiration. When starting a clothing company a few years back I began reading lots and lots on business. I read books on leadership, economics, small business, marketing etc. Being the keen student I was I began to follow the rules to success religiously (as they were outlined by the numerous books on the topic). Obediently I developed product workflow, marketed my products, studied my customer, found a niche, and developed the brand. As the sole designer for the clothing company its identity and ‘edge’ was hinged on my design ideas. And then one day, out of the blue, the ideas stopped. I worked harder to come up with new ideas, but it felt like I was squeezing water from a stone. WHAT HAPPENED? I had done everything right hadn’t I?

In short I had lost my inspiration. As I was personally funding the company I began to shop less, focused on redirecting any income I had back into building the company. Shopping less meant I wasn’t buying as many clothes for myself. For me buying clothes inspired me, I would look for a shirt and then start thinking, ‘Oh if only they made it this way, or with a different design’. Ironically the thing that I had stopped doing was the very life blood of the ideas that spurned on the company.

I began to refocus the direction for the company as my ideas for new designs had all but disappeared. During this process I took some time off and started shopping more. Then a lightbulb came on. Ideas began flowing quickly again and I realized what had happened. Fast forward to the present, I have since moved on from the clothing industry, and am working on a few internet related businesses. I have come to the conclusion that for myself inspiration is as important for every business endeavor I work on as is the motivation that keeps driving them. For this reason I am somewhat surprised that there isn’t more written on this topic.

In summary I have learnt that for me to remain successful and creative I must find what inspires me. And then using this knowledge, create situations where I am inspired. For some that might mean taking more time to walk in a forest and for others it could mean simply reading a book or a magazine, whatever it is, find what inspires you and make a point of doing it, it may mean the difference between success and burnout.