Saturday, May 26, 2012

MySQL server socket

This error is pretty common:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
The solution is fairly simple, though. In the terminal type the follwing:
service mysqld restart

Wednesday, May 2, 2012

JavaScript capture groups

/\w+-(\d+)-\w+/.exec('foo-36-bar')[1];
//   ^   ^
//   |   |
//   L___L_________ The capture group
//

This JavaScript regex extracts the number 36 from the string.

P.S. The index is 1, because index 0 will yield the entire string.