Thursday, February 26, 2015

Things about vim

Find replace

Show line numbers

:set number

Replace using ranges

Insert # at begin of line from line 1 to 10
:1,10s/^/#

Find each occurrence on each line and replace

:%s/find/replace

e.g:
:%s/^0/27

Find each line starting with 0, and replace the zero with 27

Sort, removing duplicates

:sort u

Thursday, January 08, 2015

MySQL - create database and user quickly

I'm not a MySQL fan. I don't use it enough to remember some basic things.

mysql> create database mydb;
mysql> create user 'myuser'@'localhost' IDENTIFIED BY '*******';

mysql> grant all privileges on mydb.* to 'myuser'@'localhost';

Wednesday, January 07, 2015

Things about python that I constantly forget (hate)


SyntaxError: Non-ASCII character '\xe2' in file blah.py on line 67, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details

Gaaaaah!

Put at top of file:
# -*- coding: utf-8 -*-