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'

Monday, September 28, 2015

Changing a CVS log entry after commit

bargabus@devfrench$ cvs admin -m 1.12:"`cat /tmp/x`" bookpub/lib/BookPub/Import/Importer/Amazon/Version15.pm
RCS file: /var/cvs/tools/bookpub/lib/BookPub/Import/Importer/Amazon/Version15.pm,v
done


Or instead of catting that tmp file, you can just do the text.  The tmp file was multiple lines long.

Tuesday, July 21, 2015

Adding a directory recursively to CVS

First add the enclosing directory and cd into it.  Then add all the directories except CVS.

find . -type d \! -name CVS -exec cvs add '{}' \;

Then add all the files, except any in the CVS directories.

find . \( -type d -name CVS -prune \) -o \( -type f -exec cvs add '{}' \; \)

Monday, June 22, 2015

Unique column values in OO.org and Libre Office

  1. Select the whole column
  2. Data > Filter > Standard Filter
  3. Change 'Field Name' to -none- , click on 'More options' and check on 'No duplication' box

Tuesday, May 26, 2015

Changing text cells to numbers in OpenOffice

The text cells all have a leading apostrophe.  The apostrophe isn't really part of the cell content, it just signifies that the cell is formatted as text. To reenter all the data as numbers:

1. Highlight all of the cells and use Format -> Cells to change the cell format to an appropriate number format.
2. With all of the cells still selected, go to the menu Edit -> Find & Replace
3. In the Search For box enter .* (period asterisk)
4. In the Replace with box enter &
5. Select More Options and check Current Selection Only and Regular Expressions
6. Click Replace All