14 Ağustos 2012 Salı

Using GIT to Manage Config Files

To contact us Click HERE


One thing I like about GIT, among others, is that it creates a repository locally. This makes simple things easy, still not disallowing complex things.

A good use of GIT is to manage the configuration files in a GNU/Linux system. This article describes the way I do it.

In this example, I will use the Squid proxy/cache server configuration as an example, but the principles apply to any configuration.

Ok, so here are the steps.

Zeroth step is to install GIT. ;-) On Debian/Ubuntu systems, install the "git-core" package.

First create a git repository in /etc/. On Ubuntu systems, you may have to use "sudo", or become root with "sudo -s" before running the following commands.

# cd /etc
# git init

This will create a GIT repository in /etc/.git/. This step needs to be done only once. Any recent version of GIT should accept the "init" command, otherwise run "git init-db".

Now add and commit a file, so GIT will create the "master" branch. We add the "hostname" file in this example.

# git add hostname
# git commit -m "Initial commit." hostname

If you don't use the "-m" option, GIT will start an editor to enter a comment.

I prefer to use three branches.

master: This is the branch that holds the working configuration of the running system.
stock: This branch contains the "default" configuration files as installed.
play: This branch is used for experimenting.

Now that the "master" branch is already created, let's create the other two.

# git branch stock
# git branch play

You can always use "git branch" command to see available branches with active branch highlighted.

In this example, we install Squid, and manage its configuration file /etc/squid/squid.conf using GIT.

Let us switch to the "stock" branch, install Squid, add the config file, commit it, and switch back to the "master" branch. Switching to a branch is called "checking out".

# git checkout stock
# apt-get install squid
# git add squid/squid.conf
# git commit -m "Adding stock config file." squid/squid.conf
# git checkout master

It is always a good idea to switch back quickly to the "master" branch, as we need to keep the "stock" branch clean without any of our changes going there accidentally.

Now you will notice that the "squid/squid.conf" file has gone missing, because we added it in the "stock" branch, not in "master".

To get the config file to the "master" branch, we need to merge it with the "stock" branch.

# git merge stock

I do all my experimenting, however small, in the "play" branch. Before starting an experiment, I switch to the "play" branch and merge it with "master", so both "master" and "play" will be identical at the beginning.

# git checkout play
# git merge master

Now the experimenting begins. I would change the config file, start/restart Squid, and 1001 other things.

During experimenting, it is very useful to view the changes I have done by using the "git diff" command.

Even if the experiments are not successful, I would still commit any partial work to continue later. There is nothing to worry as we are in the "play" branch. Use the "git branch" command to verify this.

# git commit -m "Partially finished experiment." squid/squid.conf

To get the system back to its previous state, we can always switch to the "master" branch.

# git checkout master

Make sure to commit the changes in the "play" branch before checking out the "master" branch. Otherwise, those changes will be lost.

Once the experimenting is successful in the "play" branch, we can merge them to the master branch.

# git checkout master
# git merge play

When backing up the system, make sure you include /etc/.git/ to save the history of your configurations.

Use "git log" to view the history of commits.

Happy gitting!

Removing carriage returns from MS-DOS (^M) in VIM

To contact us Click HERE


If you ever try to edit a MS-DOS file, you'll notice that each line ends with a ^M character. This is caused by the funny way that MS-DOS treats the end-of-line. (For some background on this problem take a look at The EOL Story.

Remove the ^M in Vim

To remove the ^M characters from a MS-DOS file, enter the command:

:%/{Ctrl+V}{Ctrl+M}//{Enter}

This command starts with a colon (:) to tell Vim to enter ex mode. All ex start with a line number range, in this case its from the first line (1) to the last ($). The slash indicates the start of the "from text". The {Ctrl+V} tells Vim to treat the next character as a regular character even if it's a special one. The next character is {Ctrl+M}. (This would be treated as {Enter} without the {Ctrl+V}.) The next slash ends the "from text". What follows is the "to text" enclosed by slashes. In this case it's nothing (//).

Not display the ^M

You also can
:set fileformats=dos
It will hide the ^M's, without touching the file.

Using dos2unix

There's a program called dos2unix that should strip those for you. Windows uses different line-ending characters which is why that happens.
dos2unix

Ho-ho-hold the phone: Santa’s on the line

To contact us Click HERE


Last year, Santa got his very own Google Voice number, and people around the U.S. received a special personalized holiday phone call from Santa Claus.

This year, Santa wants you to reach out to him (after all, reindeer are only so-so conversationalists). If you or your family members have a special request for Santa, you can call him right from Gmail* and leave him a message at his Google Voice number: 855-34-SANTA. Santa won't be able to return messages himself—it’s a busy time of year for him—but he's promised to keep us up to date on happenings in the North Pole day by day.

You also can create and send a unique, customized phone call from Santa to anyone you know, from your nieces and nephews to old college friends, over the phone (to U.S. numbers only). Listen to a sample phone call, and send a message of your own from SendaCallFromSanta.com.

Of course, Santa is never one to fall behind the technological times (word on the street is that Rudolph’s nose was recently upgraded to an energy-efficient LED). So while the red suit may never go out of style, this year Santa has come up with an extra special way to spread the holiday cheer. But you’ll have to wait until it’s closer to Christmas to find out what it is. So no peeking—but keep checking the site!

Happy Holidays from your friends at Gmail.

*Calls from Gmail are free for U.S. and Canadian users, but will cost people outside those areas $.01/minute (plus any applicable VATs).

Cross-posted on the Official Google Blog

Scribbles for Gmail for mobile - a creative way to email

To contact us Click HERE


From prehistoric humans etching in caves to the modern-day thinker sketching a stroke of genius on a napkin, scribbling is a natural form of human expression. Not constrained by formatting or font styles, scribbling is a versatile outlet for expressing individuality and creativity. Not to mention it's a lot of fun.

Now you can quickly convey that eureka moment to a colleague, or simply brighten a loved one's day with a personal scribble in Gmail for the mobile web browser and the Gmail app for iOS. In the compose view, click on the scribble button to open up the drawing window. A lightweight interface makes it easy to get your idea down.

Need a bit of inspiration to get started? With the holidays just around the corner, it's a great time to send a handmade, festive greeting:


Or, perhaps your wit is better-expressed pictorially than textually. Use scribbles to send original comics to your friends, or generate a new meme:



Simple requests are that much more appealing from someone who puts in a bit of effort:


It’s also great for simply emoting beyond the limitations of plain text:


At the end of the day, it's a blank canvas. What do you want to share? To get started, head to mail.google.com on your iOS 4+, Android 3.1+ or Playbook device, or download the Gmail app for iOS from the App Store today.

We want to see what you can do! Send your scribbles to gmailscribbles@google.com and then share them with the world using #GmailScribbles.*

Brought to you by the Gmail team. Happy Holidays!


*By emailing your scribble to gmailscribbles@google.com, you give us your permission to upload, share or reproduce your scribble both digitally and physically. Unfortunately, we will not be able to showcase all submitted scribbles, and will have to pick and choose amongst the ones that we receive. Remember: have fun and be cool about it - nothing offensive and nothing that violates the law. Thanks!

Video chat face-to-face-to-face with Hangouts in Gmail

To contact us Click HERE


Since the introduction of Gmail video chat back in 2008, many of you have told us that you love the direct, personal communication it provides. That's why we're excited to announce that video chat is being upgraded to a more modern video calling technology -- Google+ Hangouts.

Unlike the old video chat, which was based on peer-to-peer technology, Hangouts utilize the power of Google’s network to deliver higher reliability and enhanced quality. You’ll be able to chat with all the same people you did before and, in fact, with Hangouts you’ll now be able to reach them not only when they are using Gmail but also if they are on Google+ in the browser or on their Android or iOS devices.

All Gmail users will benefit from this upgrade, but if you and the person you're chatting with also use Google+, you’ll get even more from the Hangouts experience. You'll be able to video chat with up to nine people at once, watch YouTube videos together, collaborate on Google documents and share your screen. Plus, Hangouts has a bunch of fun effects that you can try out...because any conversation is better when you're wearing a virtual mustache or pirate hat.


We’ll be rolling out Hangouts in Gmail starting today and then gradually over the coming weeks. We hope you enjoy hanging out with your friends and family. Arrrgh!