Sunday, July 10, 2011

Facebook Dis

Have you ever been alone, minding your own business, and suddenly realize that someone has been following you, watching your every move, for the past two hours?

That's what it feels like when I'm visiting different websites and I suddenly see:


"[various friends] like this."

The scary thing is that the stalker metaphor is quite appropriate – Facebook really is stalking you, keeping track of wherever you go whenever you see one of these.

So I really liked a Chrome extension called Facebook Disconnect.  Unfortunately, it tends to break some sites (Scrabble, in particular).  So I extended the extension to allow whitelisting certain sites.

Presenting:  Facebook Dis.

If you really want to get fancy you can read the whitelist from a specific URL, say a website or public Dropbox file.  This lets you to configure several installations of Facebook Dis in a single place; all instances will stay up to date automatically the next time you open your browser or click "refresh" from the options page.

Thanks to Brian Kennish for the original Facebook Disconnect.

Thursday, March 31, 2011

Fast Make for Vim

2019-02-12 update - Added g:Make_quickfix_always_open option.

2014-05-18 update - This is now vim-make on GitHub.

I wasn't really satisfied with Vim's :make behavior so I wrote a script to do what I wanted.
  • Saves buffer first
  • If there are errors, show them in the quickfix window
  • Success is reported in the status bar
  • Saves some keystrokes, especially if mapped to F5
Here it is. You can put it in ~/.vim/plugin/Make.vim, or if you are using pathogen, ~/.vim/bundle/Make/plugin/Make.vim.

This is basically my first Vim plugin so please let me know if there are things I could improve.

"=============================================================================
" File: Make.vim
" Author: Victor Shih <victor.shih@gmail.com>
" Last Change: 2/11/2019
" Version: 0.02
" WebPage: http://blog.vicshih.com/2011/03/fast-make-for-vim.html
" Description: Modestly enhanced `make` for Vim.
"

function! Make(args)
  " Compile arguments.
  let l:args = strlen(a:args) ? ' ' . a:args : ''
  let l:title = expand('%') . ' - Make' . l:args

  " Force write.
  silent update!

  " Find the closest directory to the current file with a [Mm]akefile.
  let l:makefile_dir = s:find_makefile_dir()

  " Move to that directory and make.
  let l:out = split(system('cd ' . l:makefile_dir . ' && make' . l:args)"\n")
  let l:len = len(l:out)

  " Output to quickfix.
  cgetexpr l:out
  let w:quickfix_title = l:title

  if g:Make_quickfix_always_open == 1 || l:len > 1
    copen
    cc 1
  elseif l:len == 0
    " No output; just report success.
    cclose
    redraw
    echo l:title . ' succeeded'
  else
    " Output is a single line; echo it.
    cclose
    cc 1
    redraw
    echo l:out[0]
  endif
endfunction


function s:find_makefile_dir()
  let l:dir = expand('%:p:h')

  while 1
    " Ensure we have only one '/'.
    if !empty(glob(substitute(l:dir, '/$''''') . '/[Mm]akefile'))
      return l:dir
    else
      let l:parent = fnamemodify(l:dir, ':h')
      if l:parent ==# l:dir
        " We reached the root but didn't find a Makefile.
        return '.'
      endif

      let l:dir = l:parent
    endif
  endwhile
endfunction


" Register command.
command-nargs=? Make call Make("<args>")

let g:Make_quickfix_always_open = get(g:, 'Make_quickfix_always_open''0')
let g:Make_loaded = 1

Monday, November 29, 2010

Ruby Autoflush

Google seems to need help with this particular association, so here goes.

In Ruby, to flush currently buffered data just once, call flush on the handle in question:
STDOUT.flush
To "autoflush", or continuously flush output immediately, set the sync attribute:
STDOUT.sync = true
References: flush, sync

Sunday, April 25, 2010

Keyboard Shortcuts for Facebook Photo Tagging

Finally got around to tagging some photos in Facebook. I probably would not have bothered, had gleeBox not made it a bit tolerable by providing some form of keyboard shortcuts for the process:
  • Created an "ESP vision" for the Page URL
    facebook.com/photo.php
    with the jQuery selector
    #photoactions>a[onclick],input[type="submit"]
    #photoactions>a:first-child,input[type="submit"]

  • Changed my "Shortcut to launch gleeBox" to ";"

This allows tagging to go as follows:
  • Navigate to a Facebook photo album

  • Press ;<ENTER> with left hand to enter tagging mode

  • Tag at will

  • Press ;<ENTER> again to leave tagging mode

  • Left-click photo to move to the next photo

With the target crosshairs, it's about as close to an FPS you can get.

7/24/10 Update: Updated to skip new "Share" link.

Thursday, April 15, 2010

Mac Remote Desktop Connection Keyboard Shortcuts

To send the three-finger salute, Ctrl+Alt+Del, to a Windows box when you are connected using a Mac via Microsoft's Remote Desktop Connection, try Ctrl+Option+Delete (backspace).

Sunday, April 4, 2010

Edit "Save Password" Exceptions in Google Chrome for Mac OS X

If you're a Google Chrome for Mac OS X user and you've ever hit "Never for this site" by accident (or have girlfriend who does so consistently), it's a little tricky finding out how to edit these "Save Password" exceptions. It's pretty clear for Windows' Chrome:

http://www.google.com/support/chrome/bin/answer.py?hl=en&answer=156325

but I had trouble finding a solution for the Mac. A little snooping reveals that Chrome keeps its login information in a SQLite database file:
~/Library/Application Support/Google/Chrome/Default/Login Data
To remove an entry from the exception list, do the following:
  1. Shut down Chrome

  2. Probably a good idea to make a backup of the database file

  3. Open the database file in a SQLite database browser; I use SQLite Database Browser

  4. Select the "Browse Data" tab

  5. Sites for which "Never for this Site" has been selected will have the value 1 for the column blacklisted_by_user. Double-click the desired cell, change the value to 0, and click "Apply Changes"

  6. Save and close the database file

  7. Restart Chrome