Google has an Apps Script platform which allows you yo write scripts for most of Google products, such as Gmail, Drive, Spreadsheets, etc. The google script (extension .gs) is an JavaScript language subset. Google provides online editor for scripts, which is available at script.google.com. The editor is an online IDE with basic autocompletion support, which is really nice. But I prefer to write Google Scripts in some mature desctop editors such as Visual Studio or at least Sublime Text.

I came across need of writing Google Script, when I wanted to sort my GitHub notification and remove some subscription emails.

Ok, lets start. First, open the script.google.com page in your favourite browser. The page will ask you to choose an project type, or open recent project.

I'm going to select the "Blank Project" option.

If you click on "Untitled project" you'll be able to give a sensible name for your project.

Usually people have different preferences on tabs vs spaces. Here is a git filter to convert tabs to spaces, and spaces to tabs. Git allows you to write filters - a small commands which will be run after checkout (smudge) or before add (clean). As usual all settings are stored in git config files.

To make a work I use two GNU tools expand (converts tabs to spaces) and unexpand (converts spaces to tabs). If you are using Windows, then you'll need these tools to be reachable from your PATH environment varible. You can get this tools as part of GnuWin32 or any other port of GNU tools to Windows.

DISCLAMER: Be really careful before commiting, as these filters can produce a huge changesets.

Tabify - spaces to tabs on add

Open your ~/.gitconfig (%SystemDrive%\Users\<username>\.gitconfig in case of Windows)

Add following lines

[filter "tabify"]clean=unexpand --tabs=4 --first-only

It says that we want to convert each 4 space characters at the beginning of a line to one tab.

To make the filter active add following lines to your .gitconfig (or to .git\info\attributes)

*.cs filter=tabify

It says that for files with ".cs" extension we want to use this filter.

Spacify - spaces to tabs on add

Open your ~/.gitconfig (%SystemDrive%\Users<username>.gitconfig in case of Windows)

Add following lines

[filter "spacify"]clean=expand --tabs=4 --initial

It says that we want to convert each tab character at the beginning of line to 4 space characters.

To make the filter active add following lines to your .gitconfig (or to .git\info\attributes)

*.cs filter=spacify

It says that for files with ".cs" extension we want to use this filter.

Spaces2Tabs - spaces to tabs on add, and tabs to spaces on checkout.

This filter is just a combination of previous two filters. This filter is usefull if your repository requires you to use tabs for indents, but you prefer spaces. The code

git apply-url - Apply a patch to files and/or to the index from url

The alias itself is pretty simple. First it declares callable function f and then calls it. The function itself calls curl in silent mode with first argument passed to alias as url. Then it pipes curls output to git apply with remaing arguments. This alias applies the patch but does not create a commit.

Usage

$git apply-url http://example.org/sample.patch args

The first argument MUST be an url for a patch, other arguments will be passed to git apply.