Archive for the ‘computers’ Category

 

Ruby 1.9 – Tap my Object

posted by Arkham on October 28th, 2011

Let’ say you need to debug this piece of code:

very_cool_method(egg, sausage)

What would you do? I guess something along the lines of:

spam = very_cool_method(egg, sausage)
p spam

Well, Ruby 1.9 let you do something cooler instead:

very_cool_method(egg, sausage).tap{ |s| p s }

The cool thing about tap is that you can use it to eavesdrop method chains:

very_cool_method(egg, sausage).tap{ |s| p s }.now_make_sandwich_from(bacon)

Hooray! :)

Tags: , , , ,

This relationship is headed…

posted by Arkham on March 2nd, 2010

http://www.youtube.com/watch?v=JVfVqfIN8_c

  • Hey
  • Mom, Dad, this is Ryan.
  • Oh so this is the famous boy we’ve been hearing so much about.
  • Nice to finally meet you Mrs. L33T. And sir.
  • So, Ryan, what Warcraft server do you play on?
  • Is that on umm is that on the computer? Oh you know what, i think i forgot the desert in the car.
  • Who do you think you are bringing his kind into my house!?
  • But dad, he’s a nice guy, really.
  • No he’s a n00b Jessica, a n00b!
  • But ryan and I are perfect together.
  • This relationship is headed for an epic fail, young lady. You’re a L33T damn it, we don’t date n00bs, we pwn them!!
  • Well maybe I don’t want to be a L33T!
  • Your insolence, for the lose!
  • No, maybe I looove that he watches VHS tapes still. And maybe i love that his phone still has a cord.
  • You might as well date someone who plays Aliance.
  • I date whoever I want!
  • Over my level 80 rogue’s temporary dead body!
  • Mr. L33T, I may run around in circles when I play halo, and I might never get a monster kill, well, I can’t even find the space bar half the time. But I know when I find true love, and that is worth more than all the uber gear in the world.
  • Too long, did not listen!

Tags: , , ,

Trust WB-1400T on Archlinux

posted by Arkham on October 16th, 2009

wb-1400t

Run as root:

modprobe gspca_pac207

Enjoy :)

Tags: , ,

Another 17 Vim Tips

posted by Arkham on October 6th, 2009

success_vim

  1. <Ctrl>-k + e + ! – Write ‘è’ character.
  2. <Ctrl>-k + e + – Write ‘é’ character.
  3. !!date – Insert date in current line.
  4. g, / g; – Jump back/forward to the locations that have been edited.
  5. zf – Fold selected text.
  6. zfa} – Fold the function enclosing the cursor.
  7. zR / zM – If foldmethod is set, open/close all folds.
  8. <Ctrl>-w + (-/+) – In splitted views, reduce/increase current zone height.
  9. <Ctrl>-w + (</>) – In splitted views, reduce/increase current zone width.
  10. :vimgrep /pattern/ files – Search for pattern in the provided list of files.
  11. :cn and :cN to jump between vimgrep results.
  12. :clist to display all vimgrep result and :cc number to jump to a specific one.
  13. :%s/\<and\>/or/g – Replace all occurences of “and” with “or”, leaving words like “demand” unchanged.
  14. :%s/foo/bar/gi – Replace case insensitively.
  15. * / # – Search for the next/previous occurence of the word under the cursor.
  16. /\cfoo\Cbar/ – Matches “foobar”, “Foobar” and “FOObar”.
  17. /\([a-z]\)\([a-z]\)\2\1/ – Matches “abba” and “deed”.

Tags: , , , ,

17 Vim Tips

posted by Arkham on October 5th, 2009

vim_bar

  1. <Ctrl>-o – Switch from insert mode to command mode for one single command.
  2. vim +linenumber file – Open file at line number.
  3. vim +/pattern file – Open file at first occurence of pattern.
  4. :next files – Open a list of files, each in a new buffer.
  5. :up[date] - Save a modified file.
  6. “byy + “bp – Copy a line inside named buffer “b” and paste it.
  7. <Ctrl>-] – Follow green links in documentation pages.
  8. <Ctrl>-t – Go back to the previous documentation page.
  9. >ap – Indent whole paragraph.
  10. 10dd + 2. – Delete 10 lines, repeat twice (delete 20 lines more).
  11. VU – Make the whole line uppercase.
  12. V10j + : + !sort – sort alphabetically next 10 lines.
  13. :!uname -a – Display system information.
  14. :! wc % – Display information about current file.
  15. :r!uname -a – Insert system information into the next line.
  16. gg=G – Reformat whole file.
  17. <Ctrl>-n – Start autocompletion.

Tags: , , , ,