Monthly Archives: February 2013

Google search from windows command line

Create a batch file called “google.bat”.

Put it in a directory, say C:\bat\google_cmd


@ECHO off

SET s=""
IF NOT "%1"=="" SET s=%1
IF NOT "%2"=="" SET s=%s% %2
IF NOT "%3"=="" SET s=%s% %3
IF NOT "%4"=="" SET s=%s% %4
IF NOT "%5"=="" SET s=%s% %5
IF NOT "%6"=="" SET s=%s% %6
IF NOT "%7"=="" SET s=%s% %7
IF NOT "%8"=="" SET s=%s% %8
IF NOT "%9"=="" SET s=%s% %9

pushd "C:\Program Files\Mozilla Firefox"
IF "%s%"=="""" (
START firefox.exe www.google.com
) ELSE (
START firefox.exe -search "%s%"
)
popd

Add C:\bat\google_cmd to PATH. Do this by WindowsKey-Break -> Advanced System Settings -> Environment Variables -> System variables -> PATH -> Edit… append it on the end

Now you can google search via run (WindowsKey-R) google [search term] e.g. google ferrari f40

How to create an SVN repository and keep using your existing working directory

I use Tortoise SVN

Don’t use import, it doesn’t create all the .svn files. Instead…

In windows explorer, create a new folder where you want your repository to be

TortoiseSVN -> Create repository here

TortoiseSVN -> Repo-browser

Right click -> Checkout..

Aim it at your working directory

This will check out nothing, but it will create a .svn directory in your working directory

Close the repo-browser

From your working directory -> SVN Commit

It will will now add all the files to the repo!

MYSQL to TSV / TAB / CSV

TSV (much easier to use in practice due to lack of need to escape)

SELECT *
FROM pageviews
INTO OUTFILE '/tmp/pageviews.tsv'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'

CSV (if you must)

SELECT *
FROM pageviews
INTO OUTFILE '/tmp/pageviews.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n';




Note: won’t include column names. There’s no easy way to do this from within mysql, though can be done from the command line.