17 Sep 2013
My hard-drive crashed last Saturday, which kind of pissed me off as I was planning on spending Sunday playing online with one of my mates. So I spent Sunday and Monday formatting and re-installing everything.
To my surprise: I didn’t actually loose anything. I hadn’t realised how much of my data actually lives on the cloud.
It turns out 100% of my data lives “up there”.
Over the years I guess I’ve been slowly migrating without noticing the full extent.
This is the list of services I currently use:
- Google Chrome (I keep my bookmarks and history synced across devices using my Google account)
- Steam (I use this to purchase games online, I can re-install every game I bought on the platform on a new PC in less than a day)
- Github (I host all my projects here, including personal projects on private repos. Yeah, I could use bitbucket as well I guess)
- Spotify (Online music streaming service. I haven’t downloaded iTunes nor have I accessed Grooveshark in a couple of years)
- Dropbox (I did quite a few referrals and I got bumped up to 56GB of space. Now I store all my photos, videos and music on Dropbox)
- Google Drive (Why not just use Dropbox? Well… I find Google Drive convenient for documents, so I use it for all my office-related documents)
And that is how I successfully moved everything to the cloud. Hard-drive crash? No problem. Format, re-install, wait for downloads to complete, and you’re good to go.
If you have used other cloud services in the past that you think I should add to my list of must-haves, please let me know in the comment section below.
28 Aug 2013
I got stuck for hours the other day with this problem. I’ve used triggers for years in SQL Server without a problem, however, in MySQL the implementation is a bit iffy.
One problem I ran into yesterday while trying to restore a database was error 1235:
ERROR 1235 (42000) at line 1408: This version of MySQL doesn’t yet support ‘multiple triggers with the same action time and event for one table’
I scoured Google for about an hour, and came to the conclusion that there is multiple reasons this error may appear. I explain these reasons and provide solutions for them below.
First of all, I suggest you get a list of all triggers by running the following command:
<code>SELECT trigger_schema, trigger_name
FROM information_schema.triggers
WHERE trigger_schema = '<span style="color: #339966;">NAME_OF_YOUR_DATABASE</span>';</code>
Reason #1: You can’t combine both BEFORE/AFTER with INSERT/UPDATE/DELETE
This PDF describes this issue. The problem is simple: You can’t have BEFORE_INSERT and AFTER_INSERT for the same table. You may have been updating a column BEFORE insert and updating some other table AFTER insert with the ID. I suggest you move some of this logic (maybe the BEFORE trigger) to your code.
Reason #2: AFTER_DELETE sometimes fails with error 1235
You should avoid using AFTER_DELETE triggers. Move the logic to a BEFORE_DELETE trigger if you are going to use the OLD variable. No idea why this happens, maybe it is my specific MySQL version.
Reason #3: You can’t have triggers with the same name (duplicate triggers)
Sometimes you get another error code when doing this, but other times you get the same error 1235 with no explanation. Run the “show triggers” query I stated above and look for any triggers with the same name. Always run DROP TRIGGER before creating/modifying a trigger.
Reason #4: You can’t reference the SAME TABLE you are updating/inserting to in a trigger
For example, if you wanted to set the default password for a user through a trigger upon creating a new user record, you might have tried to do this: UPDATE users SET password = ‘newPassword’;
The correct way to do this is to set the variable in the BEFORE_INSERT trigger. Example: SET NEW.password = ‘newPassword’;
Reason #5: When exporting a database (as an SQL script) you may get database definers in the script
In other words, if you export a MySQL database to a .sql file, the actual file may contain things like TRIGGER ‘mydbname’.’trigger_name’. So if you try to restore it to a database with a different name it would fail. I would have expected another error code because the database it is referencing is NOT the one I am restoring to. Anyway, you receive error 1235 for this as well.
Quick fix: Open the .sql file and replace all mentions of EXPORTED_DB_NAME
. with a blank string (i.e. replace with nothing).
Summary / TLDR:
Do not use BEFORE/UPDATE triggers on the same table for a same function (e.g. INSERT). Do not use AFTER_DELETE triggers, use BEFORE_DELETE instead. Do not have duplicate trigger names. Do not reference the same table you are updating or inserting to in the trigger, use OLD and NEW instead with SET instead of a subquery. If you are restoring a database from a backup, check that the backup does not contain mentions to the explicit database name (when restoring to a different database name).
Please remember: When creating an INSERT trigger you can only use the NEW variable, when creating an UPDATE trigger you can use OLD and NEW, and in a DELETE trigger you can only reference OLD.
20 Aug 2013
. Just last week Glenn Greenwald was detained for 9 hours at Heathrow airport as being a “terrorism suspect”. What on earth is happening?
A bug has been found, or more like hundreds of bugs, and they have been unfixed, even though the issues have been raised.
Typically, socio-political changes occur on a massive scale. Democratic republics become dictatorships, whole countries become communist states, just to turn back a few decades later. When a government breaks down, a massive change is sure to ensue.
So why don’t we implement a system of incremental changes to prevent such breakdowns in the first place? Is it THAT hard?
Most large companies with web products have bug reporting systems or community forums. In some cases the community is involved in developing the changes that are required, which then get pushed to the main code repository. Ubuntu, Google Chrome (Chromium), Wordpress, Eclipse, OpenOffice, Android, and others are examples of this. Some other companies are very open to public opinion and offer bug trackers or forums to track issues, for example: Github, MySQL, etc.
Some companies out there lack an effective means of communication, or don’t really care about what the majority of their customers think. Example: Microsoft. They screw up one version of windows, then they listen to feedback and produce a good version, then they think they can handle it from there and produce an aweful version, recognise their fault and open their channels again, and so on.
Another example is Facebook. They keep pushing unnecessary UI updates to their users, who are very pissed off. They want the core part of the UI to remain as-is. If it is not broken, don’t fix it.
Quite a few governments seem to take this stance as a philosophy: We know what is right, let’s fake some listening on our behalf but keep pushing our changes. They are not listening, and it has been backfiring on them these past few years.
The world changes fast, our societies change fast, why can’t the government change fast as well? If I was in charge, the first thing I would do would be to open-source the tax laws, the constitution, and other important legal documents. Why? The people know what is best: The majority will vote, the best ideas will be upvoted, releases can be scheduled on a yearly or bi-yearly basis, ensuring everything is kept up-to-date.
Is it really so hard to say you are a democracy and really be a democracy?
07 Nov 2012
I was quite amused by a G+ post written by Google co-founder Sergey Brin today, which in summary, says the following:
I must confess, I am dreading today’s elections. Not because of who might win or lose. But because no matter what the outcome, our government will still be a giant bonfire of partisanship.
In fact, I have thought the same for some time now. Just before the Mexican elections, I had a long debate with an ex-friend of mine about this. We talked about how there should be no political parties, but instead, individuals backed by people with similar thoughts, where they aim to change the country following X or Y strategy, without naming themselves as “conservatives” or “liberals”, but rather as politicians with X or Y views. He strongly disagreed, to the point of ending our friendship because instead of analysing and debating this rationally, he was stubborn and single-minded.
In my view, you shouldn’t divide the political system into two bands. There is always scope for one person to believe in some things from one side, and some things from the other. I believe it shouldn’t be about “the way the party does things”, but instead, more about “what will benefit the country the most”.
This article, published today on TechCrunch, briefly talks about this:
No free country has ever been without parties, which are a natural offspring of freedom,” wrote James Madison.
Of course, I believe this is absolute rubbish. Political parties are not natural offspring of freedom. Freedom is one thing, political parties are another. Whilst siding yourself with a political party can be considered freedom of choice, the choices made by political parties are often single-minded unilateral decisions which lack freedom of thought, as they are constrained within boundaries imposed by the political parties’ belief system.
The article furthermore offers the following possible solution:
One popular, if contentious, solution to bitter partisanship is a multi-party system, where multiple groups are constantly forging new alliances based on specific issues, rather than a constant zero-sum tug-of-war where each party has the same enemy on every problem.
However, I digress. A multi-party system will lead towards more confusion.
So what do we need?
What we need are intelligent, knowledgeable, enthusiastic people, who put their country before their set of beliefs, to put together a group of people with similar beliefs that will back this person, economically, emotionally and whole-heartedly, so that this person may get into office. This person would not be part of a political party, but instead, would propose a plan, establishing feasible time-lines, whilst adhering to a set of rules that would govern his/her time in office (apart from the constitution, of course).
This would also make voting much simpler of course. Don’t think left-right politics. Think alignment to values and proposals. Voting could be separated into three stages. The first stage would consist of a questionnaire, where you answer yes/no to a set of questions concerning the country, society, economy, education, business, war, and a few other factors. This questionnaire would give you a list of three candidates (and their backing groups) that fit the answers the best. The second stage would consist of an analysis of the available options, studying the background, the plan, and the ideas of each candidate. The third stage would be the actual voting process as we know it: Select a candidate, vote.
Of course, this can’t work without guarantees. Each candidate would have to guarantee that the plan will be followed, and if catastrophic misalignment of the plan ensues, that person would leave office and a new voting poll would take place.
Of course these are just a few ideas I’ve been thinking about for a while now. Implementing these may be next-to-impossible, considering the system we currently have, and the rate it takes to ‘commit new changes’. Nonetheless, I believe it would bring forth a better system.
What say thee?
18 Oct 2012
I wanted to upload a simple website based on HTML, CSS and JS files, with a few images, and a favicon. So I registered at Heroku, bought a domain name, followed the Heroku instructions on how to set up the “Toolbelt” and GIT.
So I thought I was all set up: I created a folder with an index.html page, with the text “Coming Soon…”. I set up the repository, and tried to commit to Heroku, only to receive a message similar to “This is not a code repository” or something similar. Heroku is primarily aimed at apps running on frameworks, like Ruby on Rails, Django (Python), node.js, or… ahem… PHP.
So it seemed incredibly dumb that it can handle all these frameworks, but it doesn’t let me upload a static site! So I searched about, and found out how to do this by setting a demo (barebones) ruby app, as well as a Sinatra variation. However, this didn’t convince me. First of all I didn’t want to place my code in a “public” folder. No. I was probably being a bit picky, but when I expect things to work a certain way, I get annoyed when barriers are put up in my way.
I finally figured out that Heroku allows you to publish PHP sites as well, with NO configuration needed! That’s right, just create your .php files, and it will figure out that the Heroku app should run PHP for this site, and it will auto-configure the app to run on the latest version of PHP/Apache.
So here is how you do it:
Rename your index.html to home.html or something similar.
Create an index.php file with the following code:
<?php include_once("home.html"); ?>
That’s it!
Now go to your app folder in CMD (or Bash), and commit your code to Heroku using the following:
git add .
git commit -m 'Change this to a meaningful description'
git push heroku master
And finally, you should get the following:
-----> Heroku receiving push<br id=".reactRoot[192].[1][2][1]{comment10152195294515593_36201897}..[1]..[1]..[0].[0][2]..[0].[1]"></br>-----> PHP app detected<br id=".reactRoot[192].[1][2][1]{comment10152195294515593_36201897}..[1]..[1]..[0].[0][2]..[0].[3]"></br>-----> Bundling Apache version 2.2.22<br id=".reactRoot[192].[1][2][1]{comment10152195294515593_36201897}..[1]..[1]..[0].[0][2]..[0].[5]"></br>-----> Bundling PHP version 5.3.10<br id=".reactRoot[192].[1][2][1]{comment10152195294515593_36201897}..[1]..[1]..[0].[0][2]..[0].[7]"></br>-----> Discovering process types<br id=".reactRoot[192].[1][2][1]{comment10152195294515593_36201897}..[1]..[1]..[0].[0][2]..[3]..[0]"></br>Default types for PHP -> web
-----> Compiled slug size: 9.5MB<br id=".reactRoot[192].[1][2][1]{comment10152195294515593_36201897}..[1]..[1]..[0].[0][2]..[3]..[12]"></br>-----> Launching... done, v4
Congratulations! You have published a static site to Heroku with one line of PHP code :)