Monthly Archives: September 2015

Running sendy on nginx – sendy nginx rules

Sendy lets you send newsletters for very cheap. It’s a self-hosted script that works off of Amazon AWS.

Sendy's a marketer's wet dream

Sendy’s a marketer’s wet dream

Sendy comes with instructions for setting up on apache. I had to recently setup sendy on a subdirectory called “mailer” on nginx.

These are the rules I came up with:

The important parts to consider are these lines which let sendy operate flawlessly:

 

How to turn off auto indent when pasting stuff into vim on the terminal

You can turn on automatic indenting in vim by setting the indentexpr option. You can turn it on by adding the below line to your ~/.vimrc.

While automatic indentation is almost the next best thing to baked bread, especially when you code on a remote server, it’s also painful when you want to paste something from your local machine’s clipboard, vim goes overboard and indents code like this:

Vim auto indenting

Vim auto indenting

In order to be able to paste stuff from clipboard into a file open in vim via a terminal without vim auto indenting it badly, you need to enable the paste mode.

By typing

you can enable the paste mode, which will let you paste stuff without vim indenting it multiple times

By typing

you can go back to the auto-indent mode.

This can also be toggled easily by using the following command:

Now, it can be a little bit of a pain to remember to toggle between the paste mode on and off. A good samaritan has written a vim pathogen bundle that makes this automatic.

Vim Bracketed Paste plugin lets you easily paste stuff without having to toggle paste modes.

Installing vim bracketed paste plugin is easy:

  1. Install pathogen first.

     
  2. Install vim bracketed paste

     

Hope this helps!

Excluding symlinks while grepping

When grepping for a term, I usually face troubles with having to wade through results that are duplicated because symbolic links on my codebase. Excluding symlinks while grepping would save a lot of time. Let’s look at how to achieve that.

In order to exclude symlinks on search results of grep, I use a combination of find and grep like below:

The “-H” modifier on grep prints the path to the file along with the filename in the search result.

An useful thing to do would be to ignore the .git directories which can sometimes also spoil the search results. In order to do that, you could also pipe the output of the first find command to another grep that ignores the .git folders, but it’s a little slower than using the find command solely.

The below find command does it faster than piping it to grep when you want to avoid piping it to grep.