Tuesday
Jan172012

vim and too many spaces

When pasting code into vim you can often get some really annoying spacing.

This first command re-indents the file as vim thinks it should be indented. Of course you gotta teach vim the file type you’re working with but that’s another story.

<esc>gg=G

This one deals with repteated (defined here are two or more) spaces characters within a line by reducing them to one for the whole file

:%s/\(\s\)\{2,\}/\1/g
Monday
Jan022012

Nokia Lumia 800

Be careful! This starts the Diagnostic Field Test and makes the “Diagnostics” app visible too for next time.

##634#

 

Monday
Jan022012

Coder's Toolbox

Here’s a nice handy site: coderstoolbox.net

It convers:

  • Time
    • Local vs UTC
    • Unix, ISO 8601, RFC 2822
  • Strings
    • Base64, XML, URL, ECMAScript, Character set
    • Encode, decode
    • Output: US-ASCII, ISO-8859-1, UTF-8
  • Numbers
    • Decimal, Hex, Octal, Binary
  • Networks
  • Bandwidth
  • XPath (beta)

Friday
Dec302011

"grep -o" - really quite useful 

One really quite useful command is “grep -o” - it allows you to fire off something like this:

grep -o "Location supplier=\"\w*\"" locations.xml

And the output will be the phrases matching the regular expressions that start with “Location supplier=” with a double quoted word (\w) in the locations.xml file. :-) 

Thursday
Dec082011

Piping content through SSH

Thanks to http://www.contentwithstyle.co.uk/content/4-ssh-config-tips-for-faster-remote-working/ I can avoid creating files which need to be scp’d: I can pipe the content directly:
local$ cat localfile.txt | ssh remote "cat - >> remotefile.txt"
For this to work, I have already got “remote” set up in my ~/.ssh/config. You can get much more involved in this: see My favourite example from the last site (execute commands on remote server but save the output to local) is:
ssh user@example.com "mysqldump -u DB_username -pDB_password DB_name | gzip -c" > /local/dir/DB_backup.gz