Pimp My Notepad++

Filed under: News — lars @ 11:40:54

This post is a little inspired by Pimp My Gedit post at grigio.org about plugins for the Gnome/Linux text editor 'Gedit'.

I like Gedit on Linux, but Notepad++ is my favorite text editor on Windows.  I love how lightweight it is compared to IDEs like Visual Studio and Eclipse.  But I do miss some features of a full-blown IDE, particularly around the idea of "projects" - like being able to easily find and open files within a project.

Enter the Notepad++ "SolutionHub" plug-in!

To make the below work, you need to install the plugins "SolutionHub", "SolutionHub UI", "Open File In Solution" and "Solution Tools".  This will give you the ability to search for by name and open any file in your "project" - just like CTRL-SHIFT-R in Eclipse.  "SolutionTools" will give you the ability to highlight any filename within your code (eg: require_once('something.php');) and use a keyboard shortcut to open that file - just like Eclipse's F3 shortcut.

Here's how you set it up.

  1. Install the above 4 plugins from here (I just downloaded them manually and dropped them in my plugins directory).
  2. Start Notepad++.  Select Plugins -> SolutionHubUI -> SolutionHubUI Show from the menu
  3. Here you define your solution or project.  Click "New Solution" and enter a Name.  Then click the "Path" icon and select it's root folder.  Tick the "Recursive" and "Monitored" checkboxes to ensure the files within this folder are indexed, and you can optionally add Exclusions file filter to skip any files you don't want indexed (like "jpg gif png" files).
  4. Click "Save Solution", then double-click the "Connections" value in the table at the top and enter "ofis" as a connection for your new solution.  This will associate your solution with "Open File In Solution" to make this feature work.  Then click "Save Connections".  (You can define multiple solutions/projects, but only one can have the "ofis" association at one time.  This provides a crude way of switching between solutions/projects.)

    You should end up with something like this screenshot:
    SolutionHub UI screenshot
  5. Now test your Solution by going to the menu and selecting Plugins -> Open File In Solution -> OFIS - Show.  You should see a dialog that allows you to search all the files in your solution.
  6. Now we'll define some keyboard shortcuts.  Go to Settings -> Shortcut Mapper... and choose the "Plugin commands" tab.
  7. Find the entry called "OFIS - Show" and give it a shortcut.  I personally use Ctrl+Shift+R as that's what I'm used to from Eclipse, however this is used by the out-of-the-box Macro Record.  So I have to disable this shortcut manually under "Main Menu" tab.  (Unfortunately Notepad++ doesn't warn you if there's a clash).
  8. Next, find the entry under the "Plugin commands" tab called "ST - Open document" and give this another short-cut.  This is how you open files that are referenced in your source (like F3 in Eclipse).  I personally map this to Ctrl-Shift-=.
  9. That's it!

One more tip.  If you like the RubyBlue colour theme, grab the enhanced version that includes additional language support (like java).  It's available from http://www.maxahn.com/2010/12/customized-ruby-blue-theme-for-notepad/.

Happy tapping.




Listing all permissions in PostgreSQL

Filed under: Development, SQL — lars @ 09:40:33

I've just spent some time trying to debug a permissions issue in PostgreSQL that kept giving me the error "permission denied for <tablename>" when trying to access a view - even though I appeared to have all the required permissions for the table underlying the view.

I found the following useful sql to list all user permissions on every database object, which helped me find the cause of the problem:

SELECT relname as "Relation", relacl as "Access permissions"
FROM pg_class
WHERE  relkind IN ('r', 'v', 'S')
AND relname !~ '^pg_'
ORDER BY relname;

In my case, the view was referring to a sequence that I didn't have permissions to read from, and I'd never have found this without the above SQL.




Rails dev with WEBrick really slow in a VmWare Virtual Machine

Filed under: Development — lars @ 23:03:54

I've been playing around with Ruby on Rails 3 in a linux Virtual Machine and I've found it **slow as hell**.

It turns out, that the rails development server WEBrick, by default, does a reverse DNS lookup for every incoming HTTP request on the IP address that makes the request.  This is fine when that IP address is localhost, but it's a problem when your machine is remote or virtual.

To fix this, you just need to find the config.rb file under /usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick and change the following line from 'false' to 'true':

      :DoNotReverseLookup => true,

Back to work!




Selecting and updating text in an Oracle BLOB or CLOB

Filed under: Oracle — lars @ 03:05:31

I've found it a bit of a pain today to find a (relatively) simple way to work with XML in a BLOB/CLOB field in an Oracle 11g database via Oracle SQL Developer, so I want to note it for future reference.

To UPDATE a BLOB/CLOB with a string, the string must be cast to RAW.  Declaring this as a longliteral and using it as a parameter in a procedure gets around a 2000 character limit with casting:

DECLARE
    LONGLITERAL RAW(32767) := UTL_RAW.CAST_TO_RAW('<?xml version="1.0" encoding="UTF-8"?>
<someXml> ... (Can be greater than 2000 characters) ... </someXml>');
BEGIN
EXECUTE IMMEDIATE
    'UPDATE tablename SET xml_field = :1 WHERE id = 20' USING LONGLITERAL;
END;

To SELECT from a BLOB/CLOB and have the output displayed as text, you have to cast the BLOB/CLOB field to VARCHAR2.  Unfortunately casting can only be performed on strings up to 2000 characters, so the value must be truncated for this method to work:

SELECT UTL_RAW.CAST_TO_VARCHAR2(DBMS_LOB.SUBSTR(xml_field,2000,1))
FROM tablename
WHERE id = 20

If the above doesn't cut it for you, there are less simple methods for the above that involve looping and concatenating the field together in 2000 character blocks to work around the size limit.




A mouse woke my PC up! (Windows restarting on hibernate)

Filed under: TechNotes — lars @ 20:12:29

I have a desktop PC that's 3 years old and is still running Windows Vista x64.  I recently moved house and when I set the PC up I found that every time I hibernated Vista, the PC would automatically restart instead of shutting down.  I tried messing around in msconfig, and disabled Wake On LAN in my network adapters in device manager - but this didn't fix the problem.

It turned out my humble Logitech USB mouse was causing the problem, and to fix it I just had to go into it's properties in Device Manager untick "Allow this device to wake up the computer":
Screenshot

Interestingly, when I moved the PC I probably plugged the USB mouse into a different port.  This must have reset this setting in to its default state and I needed to re-untick the above checkbox.




powered by  b2evolution | blog tool | framework | hosting