Posts

sbcl access command line arguments

$ sbcl --eval '(progn (print *posix-argv*)(quit))' two three

git delete remote branch

This is a simple example where the branch has the same name locally and remotely To create a remote branch git push origin newbranchname To delete a remote branch git push origin :newbranchname

Bash script locate base dir

BASEDIR=$(cd $(dirname $0); cd ../ ;  pwd -P)

Bash script locate self

SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)

emacs emulating vi open line below

Quoted from Stackoverflow - Original Link Below ( love this post, these three are my biggest emacs annoyences) Hi there, I am currently playing around with emacs and happy with most of the concepts. But I really adored the convenience of the three vim commands: dd,o,O Hopefully you can tell me how to mirror them in emacs :) dd  - deletes whole line, including newline, no matter where the cursor is. I found something similar to do the trick: C-a C-k C-k While  C-a  moves the cursor to the beginning of the line, the first  C-k  kills the text, the second one kills the newline. The only problem is that this is not working on empty lines where I only need to type C-k  which is quite inconvenient as I have to use different commands for the same task: killing a line. o / O  - creates a new empty line below / above cursor and moves cursor to the new line, indented correctly Well,  C-a C-o  is nearly like  O , just the idention is missing....

multi line string in bash

Multiline strings can be assigned in bash using one of these two examples. $ String='foo1 foo2 foobar2' STRING=$( cat <<EOF foo1 foo2 foobar2 EOF )

How to change your password in oracle

once you are logged in to sql developer as your userid, just say "alter user {username} identified by {newpassword}"

pinboard.in with tag javascript for iPad browser Safari

Here is the javascript to add pinboard.in to safari in the iPad javascript:q=location.href;if(document.getSelection){d=document.getSelection();}else{d='';};p=document.title;void(open('http://pinboard.in/add?showtags=yes&url='+encodeURIComponent(q)+'&description='+encodeURIComponent(d)+'&title='+encodeURIComponent(p),'Pinboard',%20'toolbar=no,width=700,height=600'));

emacs goto line

Just type  'M-g-g' aka ESC+g g

Textmate Bundle Command - Convert Backslash to Comma in Document / Selection

Textmate Bundle Command - Convert Backslash to Comma in Document / Selection perl -pe 's/\\/,/g' #Set Save "Nothing" #Set Input "Selected Text" or "Document" # and #Set Output "Replace Selected Text"

Textmate Bundle Command - Convert Comma to Backslash in Document / Selection

Textmate Bundle Command - Convert Comma to Backslash in Document / Selection perl -pe 's/[,]/\\/g' #Set Save "Nothing" #Set Input "Selected Text" or "Document" # and #Set Output "Replace Selected Text"

Textmate Bundle Command - Transpose Comma Seperated Lines to Tab Separated

Textmate Bundle Command - Transpose Comma Seperated Lines to Tab Separated #!/usr/bin/env ruby -wKU aa = Array.new STDIN.readlines.each {|e| aa.push(e.split(","))} aa = aa.transpose aa.each { |e| ; e.collect!{|f| f.strip } ; puts e.join("\t") } #Input Selected Text #Output Replace Selected Text #Key Equivalent

Textmate Bundle Command - Remove Tabs

Textmate Bundle Command - Remove Tabs perl -pe 's/[\t]/ /g' #Set Save "Nothing" #Set Input "Selected Text" or "Document" # and #Set Output "Replace Selected Text"

Display hidden and control character in Vi / Vim

Turn on using  :set list Turn off using :set nolist

Oct Dec Hex Control Character Values

Oct Dec Hex Control Character Values Oct Dec Hex Name 000 0 0x00 NUL 001 1 0x01 SOH, Control-A 002 2 0x02 STX, Control-B 003 3 0x03 ETX, Control-C 004 4 0x04 EOT, Control-D 005 5 0x05 ENQ, Control-E 006 6 0x06 ACK, Control-F 007 7 0x07 BEL, Control-G 010 8 0x08 BS, backspace, Control-H 011 9 0x09 HT, tab, Control-I 012 10 0x0a LF, line feed, newline, Control-J 013 11 0x0b VT, Control-K 014 12 0x0c FF, form feed, NP, Control-L 015 13 0x0d CR, carriage return, Control-M 016 14 0x0e SO, Control-N 017 15 0x0f SI, Control-O 020 16 0x10 DLE, Control-P 021 17 0x11 DC1, XON, Control-Q 022 18 0x12 DC2, Control-R 023 19 0x13 DC3, XOFF, Control-S 024 20 0x14 DC4, Control-T 025 21 0x15 NAK, Control-U 026 22 0x16 SYN, Control-V 027 23 0x17 ETB, Control-W 030 24 0x18 CAN, Control-X 031 25 0x19 EM, Control-Y 032 26 0x1a SUB, Control-Z http://www.asciitable.com

How to edit hex values in Vi

Image
Editing binary files   Edit Use the  -b  option to set binary mode before editing a binary file, for example: vim -b myfile.bin If wanted, you can display nonprintable characters in hex, and you can wrap lines: :setlocal display=uhex :setlocal wrap In normal mode, type  g  then Ctrl-G to display the byte number at the cursor, or type a byte number then  go  to jump to that byte (for example,  123go  will jump to byte number 123). The first byte in the file has byte number 1. The following command replaces the buffer with a hex dump: :%!xxd You can edit the hex bytes, then convert the file back to binary with the command: :%!xxd -r The above command reverses the hex dump by converting the hex bytes to binary (the printable text in the right column is ignored). http://vim.wikia.com/wiki/Hex_dump

How to enter in any character in Vi / Vim

Image
By character value   Edit It is also possible to enter any character (which can be displayed in your current 'encoding'), even a character for which no digraph is defined, if you know the character value, as follows (where ^V means "hit Ctrl-V, except if you use Ctrl-V to paste, in which case you should hit Ctrl-Q instead): By decimal value:  ^Vnnn  (with 000 <= nnn <= 255) By octal value:  ^VOnnn  or  ^Vonnn  (with 000 <= nnn <= 377) By hex value:  ^VXnn  or  ^Vxnn  (with 00 <= nn <= FF) By hex value for BMP Unicode codepoints:  ^Vunnnn  (with 0000 <= nnnn <= FFFF) By hex value for any Unicode codepoint:  ^VUnnnnnnnn  (with 00000000 <= nnnnnnnn <= 7FFFFFFF) http://vim.wikia.com/wiki/Entering_special_characters

Vi search and pattern reference

A guide to searching for anything in Vi / Vim, super complete and concise http://vimdoc.sourceforge.net/htmldoc/pattern.html

The complete vi quick reference

This doc literally has every vi command! http://vimdoc.sourceforge.net/htmldoc/quickref.html

Vi search with / for decimal character value

You search for a decimal character with the normal search /\%d{decimal number} E.g search for a space character /\%d32 To tell what a character is in command mode type :ga http://vim.wikia.com/wiki/Searching