It’s that time of the year again when I get a larger drive, refresh my operating system, and back up important files.
Ever since I’ve settled on having my home folder always be on a separated drive, it’s been really easy to change operating systems, and even moving to a different (more powerful) computer isn’t as much of a chore. If I need to upgrade storage capacity, I just copy everything in my home folder onto the new drive (either by imaging or rsync) and then make sure that when I setup the new OS, that new drive is mounted in /home.
One thing that’s been really convenient for me is the ability to even move database data along with my home folder. This has been largely because I’ve been using docker (and docker-compose) more and more on my projects. For example, one of the docker-compose.yml configurations I have for work looks like this:
While working some code to work with the Zuora SOAP API, I got bit by a strange case of inheritance behavior. It would seem that this is related to what self is bound to during the execution of the statement. Here it is, distilled to its essentials:
The Student was arguing with his Colleague about a piece of code they have written.
“Master, please settle our argument,” the student said. “My Colleague insists that the return value of a method should always be an object.”
The Master was expressionless. After some a few minutes, he finally replied. “Nil.”
The Student’s face contorted into a frown, for he was confused at the Master’s reply. “Master, I don’t understand,” he stammered.
The Master saw the Student bewildered. Apparently, the Client complained that the temple construction being supervised by the Student is not going according to spec.
“I don’t get it,” the Student sighed, “the specs are right here; they are clear, complete, and in black and white. How can he tell me that I’m not following the specs?”
The Master replied “I will answer your question, but first you must help me hang a portrait.
One night during a walk, the Master visited the Student during a project. “Master,” the Student said, “why do we have to write a failing test that exposes a bug before fixing the bug itself? Isn’t it easier to just fix the bug; our Client has complained about it, I’ve tried reproducing it myself, other colleagues can reproduce it too. It’s plain as day that the bug exists.”
The Master then asked the Student for a favor.
I was working on a feature for upcloudify that will use Slack notifications instead of email notifications. One of the challenges I faced was how to build-in flexibility for generating messages. I would want that the user be able to provide their own custom notification message, but at the same time be able to provide placeholders for items like the S3 download link.
A CodeClimate Article gave a number of ways to decompose fat ActiveRecord models, and one of them was: Extract Query Objects. I’ve been trying to explore and get myself familiar with a good standard of how to implement Query Objects, and here is my take.
I’ll be trying out a new format in these articles. I’ll be using something of a Q/A style similar to Socratic Questioning
I fat-finger my code a lot and produce a lot of typos. I do test driven development so it’s not as bad, but what’s annoying is when I typo a hash key and the test blows up with a failure due to a nil – resulting in a very confusing error message.
I wanted to make a rake task that would accept something like 1.month or 1.day as one of it’s arguments. The immediate tool I reached for was eval and it worked like a charm. However, Code Climate (the tool we use to check for static analysis) complains about eval and understandably so; the use of eval is a practice full of danger and security vulnerabilities.
I’m using it inside a rake task that is never exposed to third parties, and anyone malicious enough to run the rake task with a bad parameter to be eval’d would already have had access to the system anyway, and able to wreak even greater havoc than by running the malicious code through the rake task. I believe this is an accepted risk scenario, and Crystal (one of my colleagues who was reviewing my code) suggested that since I had a valid point, I can just turn off the Code Climate check for this particular instance.
I thought that was justified, but I also thought it was a slippery slope. I’m sure there are ways to pass in a string and have it dynamically interpreted, without having to expose the system to a security vulnerability.
Some time ago I wrote about how I set up my machine so I can program hassle-free in ruby while running Windows. It was more of a reminder to myself than anything, if I ever needed to set things up the same way again.
Fast forward to 2015. When a colleague saw my workstation and realized I was running Windows, he was quite surprised and asked me how I was doing it. I thought of pointing him to my old blog post, but I felt that:
It was outdated (the setup described was from 2012, written in 2014)
It was incomplete (it’s just a checklist of what I’ve installed)
I’ve improved on the whole setup since, and I thought it’s time to share the whole updated setup so that anyone else interested can benefit.
I had to create an automated report for finance and accounting that will send particular columns and their data in a csv once a month.
Being the lazy developer that I am, I tried looking for code that already existed. I was planning to wrap up that code in a rake task and use whenever to schedule a cron job to send the report monthly.
While I was able to find pre-existing code that did what finance wanted (I checked with them as well if the output showed what they needed), the code itself wasn’t easily convertible to a rake task.
One of the best things you can do during your hackathon presentation is to have your hack available on a publicly accessible platform. You can definitely just host your app in your local machine for the demo, but it is more powerful and impressive if you can involve everyone else in a room and get them to play with your hack during your demo.
It’s a model where every 18 months, there’s a new focus on the chip architecture: the tick is a shrinking of the chip (which requires retrofitting their manufacturing process to support the smaller size) and the tock is an upgrade of the architecture itself, using the current manufacturing process.
This is largely obsolete. I have setup a new process to deploy to Amazon S3 amd I recommend it over Github Pages.
I’m currently moving my blog posts (and collecting all my blog entries from various blogging platforms) and putting them into Hugo. In case you’re wondering how I’ve set mine up, here’s a guide of what I’ve done.
Yet again I’ve ported my blog into yet another blogging platform - Hugo. I feel so strongly that I’d be staying for quite some time on this platform that I’ve been porting over all my other posts in all my other various blogs over here.
It’s quite an interesting blogging platform. It outputs static files, which means hosting options are very cheap with a wide variety of providers.
Hi, I’m Tristan! I’m a software developer currently living and working in Kuala Lumpur.
You can find me on facebook and github @parasquid.
Like many of you, I was a self-taught programmer. It all started many years ago when I was around 9 or 10; my father had an Apple ][+ clone called Minta ][ and I spent many nights typing in programs in BASIC from Byte magazine.
After that, came QBasic in high school (I was fortunate to have studied in a more technical school that taught programming and Wordstar, among other things) as well as C/C++ and dBase/Clipper.
I was invited to pressent at the KL Ruby Brigade and I thought I shuld mix things around by talking about something not very technical but still very much relevant to the audience.
Since I’m in charge (but saying “in-charge” is a bit of a misnomer since in Mindvalley we don’t really have predefined job descriptions) of the internship program for new tech hires, I figures I should share some of the things I consider when interviewing and hiring people.
A friend asked in my Ruby Facebook group about a problem he was having that I feel I’ve encountered before (or will be encountering in the future). It’s about having to retrieve data that is associated with a join table.
Here’s the question:
I have set ActiveRecords models like these
I want to do something like current_user.boards.first.role which I expect to load the membership details of current_user AND the first board. Do you have any idea how can I achieve this? Do you suggest another approach?
I’m still in the middle of writing this article, and I probably will be always updating this.
I’ve just recently (re)installed Linux on my Acer V5 122p. Had to fiddle around with UEFI settings thinking to preserve my Windows 8.1 partition, but eventually I had to bite the bullet. I wiped the whole partition clean and turned off UEFI so my installation would be a lot simpler.
Use Swagger and Grape to create self-documenting APIs that automatically update themselves from metadata in the code. It also provides an API explorer to play around with.
During the AngelHack KL event, I (being the backend developer of the team) had to create an API to facilitate communication between the iPhone app and Twilio. Since it was a hackathon, there was not a lot of time to completely hash out API protocols (as well as explaining to my team mates how RESTful APIs work).
I was able to solve this by using Grape and Swagger. I can develop the API at my own time. When a particular endpoint was finished, I can push to production and my team mate is immediately able to see the documentation. He was also able to make use of the API explorer to test out the API’s responses to his queries.
We were able to quickly develop the whole project quickly and easily because of this, and here’s a quick look at using Swagger with Grape.
Paul Graham’s (of YCombinator fame) essay on the difference between the Maker’s Schedule and the Manager’s Schedule is a timeless piece of advice that is sadly not as well known as it should be. The essay provides an interesting, if not logical reason behind why programmer’s skip meetings called by managers, while managers often tend to interrupt programmers.
Here are some of the important points in his essay:
One of the most often used and ironically least understood concepts in the Ruby programming language is the block. If you’ve used one of the Enumerable mixed-in objects, you’ve encountered the block syntax.
It’s always easier to deal with a ruby binary that’s installed server-wide rather than a local user installation (done via rvm or rbenv). Server initialization scripts don’t need to do path magic and profile sourcing in order to find the correct binary. Here I how to install ruby-2.0.0-p195 in a way that your system administrator will love you for.
Here I show how to perform a rolling restart using Capistrano, and making sure that the load balancer (in this case Linode) properly reroutes traffic to the still-running servers while the others are being restarted.
I’m still ironing out a few bugs for the rolling deployments. The issue appears to be that Capistrano executes deploy:create_symlink in parallel so the apps still experience downtime before the restart happens. The concept itself is sound but the code is not yet production ready!!
PrivatePub is an awesome gem by the renowned Ryan Bates of Railscast fame. It provides an easy way to use Faye as a pubsub provider. Watch this episode to see it in action.
You don’t have to bundle the gem with a Rails application though; you can deploy PrivatePub standalone as a rack application in Heroku. This allows you to run PrivatePub in a web dyno instead of a worker, allowing for easier maintenance (separation of repositories/codebases) and as a side effect, save on hosting costs.
At Mindvalley employees can have any kind of hardware/software they want, provided that they can prove it is necessary for the work they’re doing, or at least it increases their productivity. In my case, I opted for the setup as seen here (picture courtesy of my colleague):
I just bought a VPS (virtual private server) a couple of days ago, and I’m enjoying tinkering with it. It’s not the most powerful beast though; it only has 64MB RAM and 128MB swap. I won’t say the name of the company I’m subscribed to since my box isn’t exactly the bastion of security, but you should be able to discern the shell provider from how I describe my escapades :D
While mucking around my computer and generally getting bored, I found a few neat programs to install. They’re really cool, and your Linux computer shouldn’t be without them :) Firefox AdBlocker - blocks ads from websites. Definitely heaven sent, as browsing becomes faster without all those ads being loaded (the extension dynamically modifies the page to comment out the ads, so they don’t get rendered). You can get to choose which ones to block too.
My data drive had some corruption as regards its file system tree, and i was forced to rebuild it. I figured I’ll just reinstall Kubuntu too since I inadverdently installed Ubuntu Desktop, which kinda doubled the applications I have on the menu.
Here are some of the things I did in order to remind myself in case my system crashes again: Make a dos partition writable - the options in fstab for the partition should be: user,exec,rw,umask=000 0 0 Get Automatix and install some of the necessary non-free software Install packages used for compiling source code: sudo apt-get install build-essential I’ll add to the list as I walk through the rebuilding of my settings.