Posts

Showing posts from 2010

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

Vi search with / for hex character value

To search with a hex value is a normal vi search with  /\%x{hex number} E.g. search for a space /\%x20 To tell what a character is in command mode type :ga http://vim.wikia.com/wiki/Searching

Vi search and replace tricks, double spacing etc

Double spacing: :%s/$/{ctrl-V}{CR}/g This command applies an extra carriage return at the end of all lines Strip blanks at end of line: :%s/{TAB}*$// Delete all lines beginning with or matching a pattern: :1,$ /^#/d Delete all (first to last line: 1,$ or g) comments lines in file. Delete all lines beginning (^) with "#" (specify text pattern). :g/#/d Delete all lines (g) containing comments (comments follow "#") in file. Delete all lines containing "#". :g!/^#/d Delete all lines except (g! or v) comment lines beginning (^) with "#". Strip DOS ctrl-M's: :1,$ s/{ctrl-V}{ctrl-M}//

Vi how to see control characters

This is a good explination http://vim.1045645.n5.nabble.com/How-to-show-all-the-control-characters-td1172632.html

Vi see character decimal value and character info

This shows you the file information what line column CTRL+g This shows you character info ga This shows you UTF-8 character info and it's decimal value g8

How to goto a vi character position

How to goto a vi character position. This will go to byte 21490 :goto 21490 While the following with go to the 200 character on a line(won't pass a new line) :200| 

bash move forward or backwards a word on command line

To move forward a word on the command line escape then f To move backwards a word on the command line escape then b forwards a word: ESC f backwards a word: ESC b

Textmate Ruby Macro - Remove Line Numbers

Textmate Ruby Macro - Remove Line Numbers #!/usr/bin/env ruby -wKU STDIN.readlines.each {|e| print e.gsub(/\A\d+/,"")  } #Set Save "Nothing" #Set Input "Selected Text" or "Character" # and #Set Output "Replace Selected Text"

bash case statement fall through

bash case statement fall through Short answer is that there isn't a fall through. Here is an example from http://en.wikipedia.org/wiki/Switch_statement . Most people just want a or functionality so here is how you achieve that. case $n in 0 ) echo 'You typed 0.' ;; 1 | 9 ) echo " $n is a perfect square." ;; 3 | 5 | 7 ) echo " $n is a prime number." ;; 4 ) echo " $n is a perfect square. $n is an even number" ;; 2 | 6 | 8 ) echo " $n is an even number." ;; * ) echo 'Only single-digit numbers are allowed.' ;; esac

Ruby sleep in milliseconds

The short answer is sleep(0.0001) for a millisecond. sleep(0.0001) The details are that it's not that simple. Depending on your platform(OS) and details on thread sleeping, which I won't go into. When you get under a second and definitely under a tenth of a second accuracy really goes down the tubes. On some computers you won't see it work on less than a second. This is a complaint on some message boards. If you need much better accuracy look into realtime linux as your OS.

Bash move forward a word and backward a word using command line shortcut keys

Bash move forward or backward a word on the command line shortcut keys Will move you forward one word on the command line ESC f Will move you backward one word on the command line ESC b

IntelliJ move a word forward on a Mac

IntelliJ move a word forward on a Mac Option/Right Arrow

Run java simple bash one liner - jar runner with jar classpath expansion

#!/bin/sh java -classpath $( echo ./lib/*.jar . | sed 's/ /:/g'):./build/somejar.jar:./build/classes $*

Bash expand Jars for Java classpath with wild card

java -classpath $( echo ./lib/*.jar . | sed 's/ /:/g'):./other-lib/somejar.jar:./build/classes com.apache.ClasswithMain

Textmate Ruby Macro - Unquote Lines

Textmate Ruby Macro - Unquote Lines #!/usr/bin/env ruby -wKU STDIN.readlines.each {|e| print e.gsub(/"/,"") ;  } #Set Save "Nothing" #Set Input "Selected Text" or "Character" # and #Set Output "Replace Selected Text"

Textmate Ruby Macro - Quote Lines

Textmate Ruby Macro - Quote Lines #!/usr/bin/env ruby -wKU STDIN.readlines.each {|e| print '"'+e.gsub(/\n/,'"'+"\n") ; print ""+(e.include?("\n") ? "" : "\"\n")  } #Set Save "Nothing" #Set Input "Selected Text" or "Character" # and #Set Output "Replace Selected Text"

Disqus world's largest django powered site

This presentation show cases the list of this Disqus did to scale it's implementation.  Looks like a nice clean implementation. http://www.slideshare.net/zeeg/djangocon-2010-scaling-disqus

This is what happens when you let google write a sentence

Google scribe created run on sentence by typing in the word autocomplete then hitting enter till it stopped and this is the sentence I got. autocomplete in their own right and do not want to be related to their particular field or industry in which they are attached to their respective owners and are strictly for viewing and printing of these books are nothing but another form of therapy for these patients is not known whether these are the only ones. http://scribe.googlelabs.com/

Git Ruby Combo - hooks and preventing checkins

Here are two example from the article below  Slaying dragons with git, bash, and ruby a on pre-commit hook for git. First setup your hook that will run before you commit. chmod +x .git/hooks/pre-commit Second test out a test for ruby debugger code left, when it should be removed #!/usr/bin/env ruby if `grep -rls "require 'ruby-debug'; debugger" *` != "" puts "You twit, you've left a debugger in!" exit(1) end Now whenever I try to commit code, it will first run a recursive  grep  over the codebase to ensure I’ve not left my debug statement in (I can be sure it always looks like “require ‘ruby-debug’; debugger” as I have it bound to a shortcut). Another example included Stopping an incomplete merge There’s been occasions where a particularly large rebase or merge creates a lot of conflicts in a file, and one of those has snuck through and rather than being fixed the inline diff has actually been committed. Time to add another check t

How to recover a text from from rm

This is a clever technique if some txt and relative size of the file is known grep -a -B 25 -A 100 'some string in the file' /dev/sda1 > results.txt Here’s what the command does: grep searches through a file and prints out all the lines that match some pattern. Here, the pattern is some string that is known to be in the deleted file. The more specific this string can be, the better. The file being searched by grep (/dev/sda1) is the partition of the hard drive the deleted file used to reside in. The “-a” flag tells grep to treat the hard drive partition, which is actually a binary file, as text. Since recovering the entire file would be nice instead of just the lines that are already known, context control is used. The flags “-B 25 -A 100” tell grep to print out 25 lines before a match and 100 lines after a match. Be conservative with estimates on these numbers to ensure the entire file is included (when in doubt, guess bigger numbers). Excess data is easy to trim out of res

Natural Watering Holes NY, CA, AZ

Image
I hope I get to make it to all these places but NY and AZ look the prettiest to me Peekamoose Blue Hole, Sundown, NY If this place doesn’t remind you of old Mountain Dew ads, you’re probably part of the Twilight generation. You know the ones—groups of beautiful young people playing in the summer sun, jumping into water, popping open a can of the electric yellow soda, while a singer reminds us that “being cool is a state of mind.” In the middle of a Catskills forest, Rondout Creek pours through a rock gap to create a deep swimming hole worthy of such rowdy camaraderie. Think jackknifes and cannonballs. The I-live-for-summer rope swing dangles over the deepest end and practically begs to be used. To find the Peekamoose Blue Hole (and your inner Brad Pitt), follow New York Route 28A to West Shoken. Carlon Falls , Yosemite National Park, CA En route to Hetch Hetchy, pull off winding Evergreen Road at the South Fork Tuolumne River for a mostly flat, two-mile hike to this rare year-round wa

How to hire a programmer

How to hire a programmer. I read this article and said great this is exactly what I tell people with a twist. Basically the steps are: Simplify your idea to smallest possible version of it. Simplify some more Summarize this idea using lots of verbs and nouns, also imagine describing things if I click A then B happens. Break down this simple project into Deliverables or Milestones. THE TWIST HIre multiple developers to complete the first Milestone. Pick the best developer to complete the rest of the Milestones. Original

Venture Capital

I am talking to the world out there... What are the VC's saying? Check out the latest in iPhone mobile. http://www.mobilecrunch.com/2010/04/08/everything-you-need-to-know-about-iphone-os-4-0/

Torn - business, engineering, venture capital vs random thoughts

I am a little torn, because I don't write enough to have multiple blogs worth of content. Additionally people don't like to follow blogs that are all over the map. Basically my content is a little too diverse(lately very tech heavy) to keep an audiences attention. What to do what to do.... Not really sure about that one. I have followed a few of my friend blogs as of late ... they are pretty good. Writing has never been a strength of mine, but a skill that I admire in people none the less. I really want to improve my writing. Did you know that Benjamin Franklin had a very interesting technique growing up when he discovered his writing was poor. He would read a famous essay or article by a master writing, summarize it's main points. They try and rewrite the article making the same points. Then afterward would do a comparison of the two. This helped make Benjamin Franklin become the great writer he was. I might try doing that one day if I can find the time. Friends