Git: How to merge your branch

gitIn this post I will show you four ways to merge your branch with the main branch, which we will call develop, of the project.

1. Merging on develop

git checkout develop

git pull origin develop

git merge yourBranch

This method is the most frequently used. It uses the recursive automatic merging method of Git to merge the changes of your branch upon the main develop branch.

2. Merging with rebase

git checkout yourBranch

git rebase develop

In this method you are applying the develop branch upon yourBranch. If there is a conflict in the process of merging the process stops and you must fix your conflicts manually which may be an advantage some developers. Moreover it does not produce a merge commit message, so it helps to keep the commit history clean.

3. Merging with pull on your branch

git checkout yourBranch

git pull origin yourBranch

git pull origin develop


Removing duplicate objects using Underscore for Javascript in Coffeescript

Below an example to show how to remove duplicate objects from an array using underscore in Coffeescript.

My answer is based on the following stackoverflow q/a:

array=  _.uniq(_.collect(initialArray, (x) ->  JSON.stringify x  )).map((v) -> JSON.parse(v))


WordPress Revisr Plugin: Connecting with Github

Revisr“Revisr is a Git and WordPress database plugin that allows you to keep track of your web projects in version control. Revisr eliminates redundant interfaces in your workflow and allows you to focus on the task at hand.” – Revisr

That sounds well and good. However, configuration required a few steps and below we document them.
It is needed to install git, create certificates, upload them to github, and also set appropriate permissions.


            1. Temporarily allow login by the www-data account.
              Open /etc/passwd with nano or vi, and replace :usr/sbin/nologin with :/bin/bash

            2. Install git.
              sudo apt-get install git

            3. Create a certificate for www-data user and set permissions.
              a) Go to www directory and change owners:

              ~/# cd /var/www
              /var/www# chown www-data .

              b) Generate a certificate:

              sudo -u www-data ssh-keygen -t rsa

              You shouldn’t enter a passphrase and you should see the correct key.

            4. Open the generated certificate and copy the text inside:
              root@server:/var/www/# cd .ssh
              root@server:/var/www/.ssh# cat
              ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOL…etc

            5. Go to Github site and upload the certificate.
              A) See step 4 of
              B) Add your specific key to the github website at:

            6. Test the connection to github:
              sudo -u www-data bash
              ssh -T

              You should see:

              Hi username! You've successfully authenticated, but GitHub does not # provide shell access.
              Type "Exit" to exit www-data terminal and type "sudo bash" to start root terminal.


              sudo bash

            7. Go to the wordpress directory and set the correct permissions. Reference:

              chown www-data:www-data -R *          # Let apache be owner
              find . -type d -exec chmod 755 {} \;  # Change directory permissions rwxr-xr-x
              find . -type f -exec chmod 644 {} \;  # Change file permissions rw-r--r-

            8. Create a github repository and then connect revisr with this:
              Use the notation for SSH remote URL ( do not use https address).
              Example: in Remote URL enter:

            9. Create a github repository inside the wordpress folder (see here for more info):
              A) Go to your folder and execute

              git init

              B) You should now be able to add and commit files using either the command line or the revisr command panel

            10. Check to see that permissions are correct for your wordpress git repository. You can run ls -lqa to check the owner and check within the .git folder as well. The following commands should be sufficient to set correct ownership to www-data:
              chown www-data:www-data -R .[^.]*
              chown www-data:www-data .

The following steps should do it. Post your comments or questions below or send me an e-mail.

How to Build a Simple Game using OpenGL in C

“OpenGL (Open Graphics Library) is a cross-language, multi-platform applicaion
programming interface for rendering2D and 3D vector graphics. The API is typically used to interact with a graphics processor unit (GPU), to achieve hardware accelarated rendering.”

So OpenGL is an open library that let us a draw graphics. In this post we will show how a rookie can build a OpenGLsimple game with OpenGL in a C environment. Specifically this game will feature a spacecraft and we will design and implement each part of it using the primitive types of  OpenGL . Moreover we will build the environment which includes  space, stars , a sun and some planets with the same way. Then we will introduce the way that we can add an animation movement. Finally we will load an asteroid from an object file that will have an orbit towards our spacecraft and the goal will be to avoid the asteroid. More

Laravel 5 and simple Forms workaround

Here is a simple example of using laravel 5 powerful forms to deliver a secure and fast result!
To make our lives easier we need to install the HTML package!

In file /compojer.json we add:
"require": {
"laravel/framework": "5.0.*",
"laravelcollective/html": "~5.0"

Next add the service provider and aliases.
In /config/app.php we update the following:

'providers' => [

'aliases' => [
'Form'=> 'Illuminate\Html\FormFacade',
'HTML'=> 'Illuminate\Html\HtmlFacade',


Laravel 5 TIPS For Beginners!

Here are some tips you might find handy when you think you have done everything according to the tutorials!

In formrequests to authorise access only for registered/signed users we add

use Auth;
public function authorize()
if ( !Auth::check() )
return false;
return true;


Redirecting varnish to new backend on the fly

varnishCache1) Change VCL backend config

Go to your vcl file (in my case /etc/varnish/default.vcl). Edit the backend param to point to another server. Also increase the timeouts since it will take longer than accessing localhost.

backend default {
 .host = "";
 .port = "80";
 .connect_timeout = 120s;
 .first_byte_timeout = 600s;
 .between_bytes_timeout = 60s;

2) Validate VCL script on the fly

sudo varnishd -C -f /etc/varnish/default.vcl

This will notify if any syntax issues exist.


3) Reload the VCL Script without restarting varnish

I utilized:

$varnishadm -T localhost:6082
vcl.load reload01 /etc/varnish/default.vcl 
vcl.use reload01


Changing user agent for RESTClient firefox extension


If you are using RESTClient (and don’t want to switch to CURL) but need to modify the user-client when testing a request, there are two ways:

  • Adding a custom “user-agent” header through RESTClient
  • Changing the user agent through an extension.

Since RESTClient is an extension, by default it uses the user-agent of firefox.

As a start we can do a test and access the page through the RestClient.


Calling Mysql Iteratively and Passing Parameters from Bash Loop

Linux and MysqlBelow we see an example of calling a mysql script from a file and passing a param.

sql script

So make a file with the following (or whatever else you wish):

SET @i = 1;
use databaseName;
SET @pID=@i+100;
SET @partnerID=concat('partner',@pID);
select @i, @pID , @partnerID;

Now, this will print out the values of i, pID, and partnerID.
Below that you could include insert statements or whatever else you wish.

Now how do we call this from bash and set the @i param?

bash script


for i in {300..400..5}
sed -i "1 s/.*/set @i=$i;/" sample.sql
mysql --user="$user" --password="$password" < sample.sql

So how does this work?
We use sed to replace the first line completely in sample.sql with a new “set @i=” command containing the i param we want.
We then call mysql and feed the rewritten file.

Another way to do this would be to concatenate the sample.sql contents to the set command, and feed them to mysql in memory.

Build a Server – Client Application in C that executes concurrently Terminal Commands

In this post we will build a server – client application that will get our hands dirty with signals, fork, named pipes and the exec command. This application has a very simple concept:

“Client creates, with a new process, the Server and sends to him terminal commands using as interprocess communication a named pipe (aka fifo pipe)”

Moreover this model must executes terminal commands concurrently and we accomplish that using a signal handler. To be more specific when a client sends through the named pipe a command, the server wakes up because the signal handler  receives the SIGCONT signal and changes the wake up variable from 1 to 0. This wake up variable is being used in the server to keep him in sleep mode and not busy waiting. Let’s see a simple example with just the mechanism of it: