Clone private VCS repository with composer


Sometimes, your Composer configuration uses a private repository to obtain a package.This usually looks like this in your composer.json file:

    "packages": {
        "vendor/package-name": "1.0.0"
    "repositories": [
            "type": "vcs",
            "url": "[email protected]:VCSvendor/VCSpackage-name.git"

The above example uses the git protocol to download from the git repository. However, what happens if we want to deploy to GitLab, where we only have credentials set up for https://.. ? Or the code previously worked on a Linux machine and we want to use it in windows, where the git protocol is not configured ? It would be terrible to have to change the file each time we need to do an install or update..

I was recently introduced to this problem and I found out something that solves the problem easily. I’m posting it here, so it helps me in the future as well.

Introducing: “.insteadOf“:

git config --global url."".insteadOf "[email protected]:"

The above command will tell Git to always substitute “[email protected]” with “”, when it encounters it. This means that when you run “composer install” or “composer update”, the URL will be switched and git will be able to download what it needs successfully.
Of course, you can remove the “–global” option and do the change on a per-project basis.

The “insteadOf” configuration saves a lot of time when trying to replace any part of a url and is a cool feature to know.

MySQL Replication with minimal downtime

The following article is taken from Bryan Kennedy’s blog. Original link:
I found the information there so valuable that I decided to save it here, as I find myself looking for it frequently.

Replication is something that provides both speed and durability. Usually it is used in environments where the loads on the database are heavy or we want to avoid downtime. However, most methods for replication online include stopping instances, which is unacceptable in a busy production environment.

In order to do it with minimal downtime (just a few restarts):

First, you’ll need to configure the master’s /etc/mysql/my.cnf (or for newer versions of MySQL /etc/mysql/*.conf.d/mysqld.conf) by adding these lines in the [mysqld] section:

binlog-format = mixed

Restart the master mysql server and create a replication user that your slave server will use to connect to the master.

CREATE USER replicant@;

Note: Mysql allows for passwords up to 32 characters for replication users.

Next, create the backup file with the binlog position. It will affect the performance of your database server, but won’t lock your tables:

mysqldump --skip-lock-tables --single-transaction --flush-logs --hex-blob --master-data=2 -A > ~/dump.sql

Now, examine the head of the file and jot down the values for MASTER_LOG_FILE and MASTER_LOG_POS. You will need them later:

head dump.sql -n80 | grep "MASTER_LOG_POS"

This file might be huge, so you can gzip it before moving it to the slave (optional):

gzip ~/dump.sql

Now we need to transfer the dump file to our slave server (if you didn’t gzip first, remove the .gz bit):

scp ~/dump.sql.gz mysql-user@:~/

While that’s running, you should log into your slave server, and edit your /etc/mysql/my.cnf (or another position, according to your MySQL version) file to add the following lines:

server-id = 101
binlog-format = mixed
log_bin = mysql-bin
relay-log = mysql-relay-bin
log-slave-updates = 1
read-only = 1

Restart the mysql slave, and then import your dump file (gunzip if you compressed it earlier):

gunzip ~/dump.sql.gz
mysql -u root -p < ~/dump.sql

To check the progress of your slave:


If all is well, Last_Error will be blank, and Slave_IO_State will report “Waiting for master to send event”. Look for Seconds_Behind_Master which indicates how far behind it is. It took me a few hours to accomplish all of the above, but the slave caught up in a matter of minutes. YMMV.

And now you have a newly minted MySQL slave server without experiencing any downtime!

A parting tip: Sometimes errors occur in replication. For example, if you accidentally change a row of data on your slave. If this happens, fix the data, then run:


Applying default permissions for newly created files within a specific folder

I’ve had to give access to multiple accounts to a single folder as a development environment in which it can be tracked who did what. I am writing this down for future reference.

Here was my goal:

Two different accounts, belonging to the same group need to be able to edit each others’ files.
We need to make all files/folders in a location belong to a certain group and then all new files and folders created in that location should also have the same ownership. They should also be group writable. Here is the desired result for newly created files:

-rw-rw-r-- 1 student1 school 0 2007-12-06 22:46 newfile

For this guide our users will be “student1” and “student2” which are both added to the group “school”
Our folder will be at /home/user1/project, so let’s assume user1 is the current owner of the folder and all files and folders in it have the following ownership: user1:user1

The first thing we need to do is change the group ownership of all of the files and folders:

chown -R :school /home/user1/project

After that we need to enable read/write for the user and group for all files and folders. Since we need 775 for folders and 664 for files, we do the following:

find /home/user/project -type d -exec chmod 775 {} \;
find /home/user/project -type f -exec chmod 664 {} \;

Now we need to use GID to set the ownership for all files and folders that will be created in the future (for any subfolder – that’s why it is recursive):

find /home/user/project -type d -exec chmod g+s {} \;

In order to set the access rights for new files and folders we will use ACL. If you don’t have it installed, you can do so by executing (for debian):

apt-get install acl

After installing it, we can set read/write permissions recursively, by defining the modes for owner and group:

setfacl -R -d -m g::rwx -m o::rx /home/user/project

It is important to note that the user’s umask plays a role when creating new files and folders. I.E. the root user in your system will most likely create files with the ownership of root:root and they will not give in to the desired permissions.
For regular users, however this should not be a problem if you have not tinkered with their umask.

That’s it. Result:
Newly created files/folders by user2 will have this ownership: user2:school
Files and folders will be writable by all users in the group, but will keep their original owner.

Like if you hate cancer! : Facebook share-scams explained

We see them in our news feed constantly.  They’re pictures that manipulate us into liking or sharing. We see a photo like this and think, “Well, heck yeah, I’d save my Momma!” … and the weird part is, we find ourselves clicking the “like” button just so everyone will know we don’t want dear ol’ mom to burn alive in a fiery ball of death.

We’re guilted into liking or sharing images that indicate our religious beliefs, political opinions, intelligence, or compassion towards others. We fall for it easily enough – after all, we want all of our friends to know what we truly stand for!  However, there’s more behind the “Share if you love God, ignore if you love Satan”  kinds of posts than allowing the Almighty to see how many people are on His (or Her, if you so prefer) side….


Yep… sorry to burst your bubble, but it’s all about money. FYI – God doesn’t need a Like Button to see where your loyalty lies.

You see, Facebook wanted to develop a way of knowing whose Facebook pages were considered the “most important”. They decided to base this on things such as likes and shares of the original post. I mean, obviously, if a Facebook account can generate tens of thousands of likes or shares of its posts on a regular basis, then that must mean that the information is important and worthwhile. It’s called EdgeRank and it’s based on the Facebook Like algorithm.  Long story short, EdgeRank helps determine how frequently your posts show up in others’ news feeds.

Now, where does all of this boil down to money?  Here, let me show you….

Businesses are always looking for a way to promote themselves online. And social media like Facebook is becoming more and more helpful to many B2C companies. However, building up such Internet influence takes a lot of time and dedication. It’s far easier just to buy an account from someone who’s already done all of the tedious work so you can just reap the benefits of it later on down the road.

So, to wrap this up and keep it short, that handsome soldier’s birthday has long since passed. The girl with Down Syndrome has no idea that you’ve liked her photo to tell her she’s pretty. If you comment on a photo to “See what happens!!”,  you’ll just see the same photo through wiser, though somewhat sheepish, eyes.  And you won’t be going to hell for ignoring a Facebook post.

Now of course, we understand that Facebook is a social platform to share those things we feel are important or humorous. Go ahead and do so. Just don’t think that your like or comment is suddenly going to raise money for that little boy dying of a brain tumor.

Now if you share this post today, starving children will get to eat…  if you don’t, terrorists will likely take over Texas with chemically-enhanced duct tape.

Your choice.

Source: Like if you hate cancer! : Facebook share-scams explained