Monday, March 28, 2016

Editing in hex mode in Vim

Native Vim doesn’t have a hex editing mode built in, however it is possible to edit a file in hex by converting the file back and forth using xxd. To do this, open your file in Vim and run :%!xxd. From here you can change the hex values and, when you’re done, run :%!xxd -r to convert back.

Tuesday, January 5, 2016

MySQL pager setting in ~/.my.cnf

I like setting the pager to less for the mysql client.  When I do it in my ~/.my.cnf file, thus...

[client]
pager=less

I get an error when running mysql dump...

mysqldump: unknown variable 'pager=less'

Turns out mysqldump also reads the [client] section of the file, as well as [mysqldump].  Using the following works...

[mysql]
pager=less

Tuesday, December 1, 2015

Autoformatting code in vim

To format a file in vim, gg=G (gg go to top of file, = format, G until end of file

More details here... http://stackoverflow.com/questions/11655383/vim-formatting-using-gg-g-with-xml

Monday, October 26, 2015

Export a CVS file from MySQL

To dump all the records from a table called "sale" into the file /tmp/sale.csv as a CSV file, use the following SQL query:

SELECT *
INTO OUTFILE '/tmp/sale.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM sale

Showing all changed file buffers in vim

So, editing a rails project in vim + NERDTree, I often edit several files and then browser refresh to check my work.  If I forget to save a particular file, it's problematic to check all the buffers. In #vim, they told me about ':ls', which shows all buffers in that session, with a + before the ones that are unsaved.  Also, ':ls +' will just show the unsaved buffers.

Also, the % indicates the current buffer, the # indicates the buffer you get to with a ':e#'.

TIL...

Saturday, October 24, 2015

rsync

I expect to be adding to this...

When refreshinging the saver directory from bargabus.com to local, get only the new files with...

rsync -ahv --ignore-existing user@bargabus.com:~/saver/* .

Friday, October 9, 2015

Using the 'less' pager in the mysql client

In iTerm2 on OS X, the default less is rather wonky in the mysql client.  I use it as my pager.  Anyway, I added the -S flag to my less options and things got better.

export LESS='-S'