Recently, I’ve had to work on a project using AngularJS and node.js. Development was eased using a Ubuntu 14.04 virtual machine, through Vagrant. Not a big deal to install, I was saying to myself, except I ran into a ton of errors with my very naïve approach (geez, what an optimistic fool I can be sometimes).
Author Archives: jmfeurprier
Truncating a file with Linux
Truncating a file?
To truncate a file is to make it empty (its size becomes 0 byte). This comes in handy for logs, when they grow too big, or when you need to re-use an existing file but want to skip the chmod/chown steps.
So, how to truncate a file?
SVN trunk, branches and tags
In this post, I provide details about how I personnaly handle SVN trunk, branches and tags. This approach is also known as “branch always”, with minor differences. This might not be the best approach, but it will give beginners some explanations on what trunk, branches and tags are, and how to handle them.
Continue reading
method_exists() vs. is_callable()
One thing I often see when re-factoring PHP applications, is the improper use of the method_exists() function, and I think this needs a little bit of clarification.
Continue reading
Simple introduction to SVN externals
Not so long ago, we’ve had to include a third-party library into a new project (using SVN). Our first idea (the one which did not imply thinking) was to SVN-export library files from the remote repository, paste them into the project, SVN-add them, then SVN-commit files.
Having to keep these library files up-to-date with official patches and improvements sounded like a full-time job.
This solution sucked.
A lot.
Continue reading
Improving performance with return values caching
Many functions (and methods) in a project will often provide the same return value for the same arguments, like:
- mathematical functions:
function someMaths($x) { return $x + pow($x, 3.2) - cos($x); }
- functions which retrieve content from a file: