everymark

code, tools Tagged with: ,
Nov 272009

everymark i have just finished writing my first google chrome extension. took my half a day overall, few of hours here and there, but compared to firefox the red-tape stuff was much easier.

actually it is very simple, you make a new direcotry, and create ‘manifest.json’ description file, it includes all of the extension official stuff, like name, version, description and permissions. it also include pointers to other files – html and javascripts.

that’s it, from here it is plain web: html/css and javascript.

one thing worth mentioning is that if you change the manifest file you need to explicitly reload your extension on your chrome://extensions/ page, otherwise things like permissions are not updated. other stuff like html/javascript files are reloaded each time you invoke your extension, so no need to do nothing on this case.

what i was working on? well, long time ago i have found out that the old school method of cataloging things and then searching them by their location is not very effective, you pay a lot of time on the WRITE side and you pay as well on the READ side, using metaphor from the database world.

the search capability of everything and sublime text projects are far better, just see all the database as one flat list and start filtering it by your search term. so that what i did on my bookmarks, and here is the result:

everymark – ‘everything’ search on my bookmark.

when clicking the icon, a nice popup will appear, populated with a list of all your bookmarks and their links, whenever you start typing search terms the list will shrink to contain only the relevant bookmarks – neat :) – any way enjoy.

everymark-screenshot

btw, for references about writing the extension i have use the following pages:

http://code.google.com/chrome/extensions/devguide.html
http://code.google.com/chrome/extensions/api_index.html
http://code.google.com/chrome/extensions/tut_debugging.html

* * *

revisions:

v1.8.3 startup speed improvements on favicons
v1.8.2 fixed selection bug on v1.8.1
v1.8.1 un-obfuscated
v1.8 show full URL as tooltip on hover
v1.7.1 show full URL as tooltip on hover
v1.7 show sites’ favicons
v1.6.1 better visualization on deletion of bookmark
v1.6 sort by date, double click to open, tooltip on extension icon
v1.5.1 filter bookmarklets (thanks to DarĂ­o Macchi), better context menu
v1.5 columns can be sorted, revised context menu
v1.4 added context menu (right click) with option to delete bookmark
v1.3.1 filter groups/folders from the list
v1.3 wraps row selection on table edges
v1.2.1 supports auto-update
v1.2 supports multiple search terms (space separated)
v1.1 supports manual selection with arrow keys and launching with enter key
v1.0.2 few minor fixes
v1.0.1 added extension icons
v1.0 initial release
Oct 042009

perla word about the power of unix shell commands: perl one liners, i.e. one line of perl that can save you hours of error-prone hand changes. when i want to do some massive changes in my code this is what i use.

say you need replcae a record name from abc_record to xyz_record, first if you use perl recursivlly it will touch all files and revision control will makr them for commit. you don’t want that. so use grep to filter the relevant files:

grep "#abc_record\b" . -rl

next, do the replace:

perl -i -pe s/"#abc_record\b"/"xyz_record"/g `grep "#abc_record\b" src -rl`

note the use of \b to mark a word boundary.

a more complex replace is if you need to change the code from using a record to use a wrapper function. so for exmaple we have the record:

-record(abc_record, {fld}).

and we want to start use a wrapper module:

-module(rtools).
-export([fld/1]).
 
fld(R) -> R#abc_record.fld.

so we can do it instantly like that:

perl -i -pe s/"\b(\w+)#abc_record\.fld"/"rtools:fld(\1)"/g `grep "#abc_record\.fld" src -rl`

here we have switched from using A#abc_record.fld to record_tools:fld(A)

another trick is to remove complete lines (!), so for exmaple you can get rid of all the -compile(export_all) you have fullishly inserted into your code:

perl -i -nle 'print if !/-compile\(export_all\)/' `grep export_all src -rl`

one safty tip, omit the -i first to try before you actuall change files.

this was just a learn-by-example, more info can be found at:
http://sial.org/howto/perl/one-liner
http://www.unixguide.net/unix/perl_oneliners.shtml

© 2010 Virtual Clouds Suffusion WordPress theme by Sayontan Sinha