Preparing Your Pull Request For Code Review

Anyone that is working in a team and is collaborating with others on writing applications is using some form of version control system (VCS). The word collaborating is the important one and to achieve a good level of collaboration, people usually create pull requests in their software development tool of choice, be it GitHub, Bitbucket, GitLab or one of many other out there.

Pull requests are containers for commits that you have done, communication around those commits and changes therein, a code review entry point as well as some other things.

Continue reading “Preparing Your Pull Request For Code Review” »

Caching Part 1: Intro

What Is Caching And Why Should You Use It?

Anyone that has ever worked with high volume sites has at some point had to optimize one or more parts of the application. The most common ways to go about that are profiling the application code and database queries. Once you know where the bottlenecks are, you have a couple of options, depending on the use case:

  • refactoring the code so it runs faster, such as extracting code from foreach loops or optimizing the SQL,
  • offloading the process to the background (I wrote about that in another post),
  • cache the results

Continue reading “Caching Part 1: Intro” »

SaltStack HowTo: Installing, Setting up and Provisioning

The problem and the solution

I work at a company that creates web sites and applications. I joined them in 2008 when there were 2 front-end developers and 3 back-end, including me. Company slowly grew to 7 back-end and 6 front-end developers. The following problem started to get in our way more and more: we were working on one single development server, which means that from time to time we would step on each other toes. What happened is, one guy would open a file, the other guy would open the same file and whoever saves and closes first, is a loser. Also, that server had to have every possible service, program and PHP extension imaginable because it needed to support a lot of diverse projects.

Continue reading “SaltStack HowTo: Installing, Setting up and Provisioning” »

Pretty HTML5 multiple file upload with Bootstrap, jQuery, Twig and Silex

There are a number of ways to achieve multiple file upload functionality, but I like HTML5 way of doing it, and it will be supported across all major browsers when IE10 ships. Also, Twitters’ Bootstrap helped me achieve the look without problems. I used a bit of jQuery for help with events. Alongside vanilla html, I will put Twig form syntax to achieve this, together with Symfony2 Form component, for server side.

Continue reading “Pretty HTML5 multiple file upload with Bootstrap, jQuery, Twig and Silex” »

Development environment

This is a quick post on how to set up your own DNS server with custom TLDso you can easily and more quickly get started on your next project. I am doing my programming on the Linux machine (Ubuntu to be Precise :)). The idea behind this set-up is to evade the need to ever modify your /etc/hosts file. Also, there is a possibility to even skip the creating of Apache VirtualHost directive and restarting the web server. Onward with the How-To.

Disclaimers:

  • I use Ubuntu, so substitute apt-get with yum or what ever you use
  • Anywhere you see the IP 192.168.1.253, replace with your own
  • I haven’t set up any forwarders in named.conf.options

Install and configure DNS (BIND9)

sudo apt-get install bind9

Edit these files

/etc/bind/named.conf.local:

zone "dev" {
    type master;
    file "/etc/bind/db.dev";
};

zone "1.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/db.192.168.1";
};

/etc/bind/db.dev

$TTL	604800
@		IN		SOA		dev. root.dev. (
	             2012042301		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
;
@		IN		NS	dev.
@		IN		A	192.168.1.253
*.dev.	14400 	IN 		A	192.168.1.253

/etc/bind/db.192.168.1:

$TTL	604800
@		IN		SOA		dev. root.dev. (
	     2012042301		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
;
@		IN		NS		dev.
253		IN 		PTR		dev.

Be careful to replace 253 in your files for your own last IP octet. Also, the filename should reflect your IP.

DNS servers setup…

Ok, now that we got this set up, we need to tell our system to use the local DNS server before going for the ISP and beyond. To achieve this, use Networking manager in Ubuntu, here’s how mine looks like. The final goal is for the /etc/resolv.conf too read: nameserver 127.0.0.1.

…and finishing up

Now that everything is set up, restart bind:

sudo /etc/init.d/bind9 restart

Test your setup by pinging anything.dev. If you get the response from your server, all is working great.

Apache Virtual Document Root

If your projects have similar / identical directory structure (i.e. public directory for publicly available files) than you can go a step further and setup the Apache Virtual Document Root. In doing so, you will be able to create a new directory in your projects root and have it magically turned up by calling http://newdirectory.dev.

<IfModule vhost_alias_module>
    <VirtualHost *>
        UseCanonicalName Off
        VirtualDocumentRoot "/path/to/projects/%1/public"

        ServerName projects.dev
        ServerAlias *.dev

        SetEnv APPLICATION_ENV development
    </VirtualHost>
</IfModule>

# Enable mod_vhost_alias apache module
sudo a2enmod vhost_alias
# Restart server
sudo /etc/init.d/apache2 restart

I don’t have this enabled for myself, but it does work, although not well tested. For further info on this topic, check the following links:

P.S. Yes, I got carried away while creating the featured image :)

MySQL Workbench 5.2.35 on Ubuntu 11.10 64bit (Oneiric Ocelot)

Well, if no one is gonna do it, you have to do it yourself. I had the need for latest MySQL Workbench – 5.2.35, but I also upgraded to the latest Ubuntu, the Oneiric Ocelot (11.10). As with most of new things, I couldn’t get it to work out of the box, so little compiling session was in order. If you need the package, you can download the deb. It is for 64bit (amd64) architecture. This is the first time I have created a deb package, so I apologize in advance if I didn’t follow some basic rules.

MySQL Workbench 5.2.35 for Ubuntu 11.10 (64bit)

Test projects viewer

I have a couple of test projects in my test directory. This is where I usually put the latest wordpress, phpBB or any other script or web software I would like to test out or develop and play with. Until recently I had to access those by writing the virtual host path (www.test.local) and then append the directory name (in.eg. /drupal). I got tired of it, and coded a nifty little “browser” which displays all of the directories and files. Combined with the DNS wildcards, you can have unlimited virtual domains without having to configure them in vhosts, setting the /etc/hosts and restarting apache server. I have included this in the zip file found at the end of this post.

We are using bind dns server to resolve everything that comes to the “test” domain to your machines IP address. After that, Apache takes care of the rest. And what he does is kinda cool. The .htaccess file has a set of rules to test weather the index.php exists in the requested directory (via subdomain), and if it does, he redirects us to that directory. If the index.php doesn’t exist, our “main” index.php shows the contents of that directory, so you can select any other file and run it. Let’s start.

Continue reading “Test projects viewer” »

I got the (mt) hosting

I’ve seen a lot of hosting servers. Really a lot, I’m a developer. 99% of the time, they had cpanel, 99% of the time, one couldn’t optimize and setup his hosting place to meet his needs. That’s not because of the cpanel, of course, but because of the hosting company. My appetite for features and freedom of configuration got bigger over the years, so I got myself the  (gs) Grid-service hosting plan on Mediatemple. Upon sighting the /etc directory in my root, I got excited.

Continue reading “I got the (mt) hosting” »