Code and Hacks

(Perl, js, vim, bash, machine learning and more...)

Setting the Terminal Title in Gnu Screen April 11, 2010

I often have multiple terminals open and screen running in each one. I then try to group all my work for a particular project in that terminal. While I am trying to limit the amount of multitasking and concentrate on one thing at a time, I might leave a terminal/screen session up for days and when I come back I can jump right back where I started.

More...

Open Source Presentation Software April 01, 2010

I am thinking about giving a presentation at one of my local Perl Monger meetings. So as usual, I have spent a bunch of time toying with new tools rather than getting work done! Which tools: open source presentation creation software. I wanted something that would take a simple text file and easily create an attractive and easy to use presentation.

Here is a quick summary of the options that I tried or looked into:

More...

Backup Current File March 01, 2010

Here is another AppleScript version of a prior vba script. This one creates a back of the current workbook. It copies the last saved version of the current workbook to a Backup subdirectory below the directory in which that file was saved. It adds a counter (ie, .001) before the .xls(x) extension.

More...

Office:mac Auto Color Cells February 28, 2010

I recently switched to a Mac and really miss my auto color cells VBA script for Excel. After quite a bit of digging (and trial-and-error) I managed to recreate the functionality using AppleScript. It is pretty slow, but it works!

Just like the VBA version, this automatically color codes cells to help identify inputs, formulas, etc. For example, cells that contain only numbers are colored blue, all formulas black, references to other workbooks are green and cells that include the =OFFSET() function (what I use for setting up different scenarios) are rust.

Open up the AppleScript Editor, paste the following code and save it as /Users/<your-username>/Documents/Microsoft User Data/Excel Script Menu Items/AutoColorCells\scc.scpt. The \scc in the filename creates a keyboard shortcut control-shift-c.

More...

Align Center February 28, 2010

Rather than merging cells to center headers, I prefer to have text centered across selection. This avoids problems with deleting and filling columns that are cosed by merged cells. The following sets up a command to toggle centering across columns.

Open up the AppleScript Editor, paste the following code and save it as /Users/<your-username>/Documents/Microsoft User Data/Excel Script Menu Items/AlignCentered\sca.scpt. The \sca in the filename creates a keyboard shortcut control-shift-a.

-- Align selected cells across selection
-- Copyright under GPL by Mark Grimes
-- Saving with '\sca' in the filename creates Shortcut: Crtl+Shift+a

tell application "Microsoft Excel"
    --activate
    tell range (get address selection) of active sheet
        if (get count columns) > 1 or (get count rows) > 1 then
            if (get horizontal alignment) is horizontal align center across selection then
                set horizontal alignment to horizontal align general
            else
                set horizontal alignment to horizontal align center across selection
            end if
        else
            if (get horizontal alignment) is horizontal align center then
                set horizontal alignment to horizontal align general
            else
                set horizontal alignment to horizontal align center
            end if
        end if
    end tell
end tell

Making Catalyst Debug Logs Really Be Quiet October 20, 2009

I have recently been adding and updating tests to my biggest Catalyst project and have been a bit perplexed by the debugging output…in particular that I was seeing any of it! Generally, I like to see all that output scroll by, but when running Test::WWW::Mechanize::Catalyst tests over and over again, it just clutters things and obfuscates any failures.

I had removed -Debug from the plugin list and tried CATALYST_DEBUG=0 env variable, but I continued to see a lot of the debug messages. After a bit of Googling, I finally learned that this was a feature.

More...

Moving to a Mac... which Perl? October 13, 2009

We’ll after neglecting this blog for quite some time, I’m now back. I had to swap my laptop during the summer, and I decided to give one of the MacBook Pros a try. So I’ll be adding Perl on the Mac and the Mac in general to the topics covered here. My first dilemma with the new Mac was which perl to use.

More...

Stealing from Padre for Vim part 3 July 03, 2009

As promised in my last post I have released a new version of App::EditorTools and have a number of screenshots of the new functionality. This version includes App::EditorTools::Vim, which provides an easy way to add the vim scripts to integrate the package into Vim.

perl -MApp::EditorTools::Vim -e run > ~/.vim/ftplugin/perl/editortools.vim

And now you should have the following mappings:

  • ,pp - Show a menu of the functions available from App::EditorTools
  • ,pL - Lexically rename the variable under the cursor (make sure the cursor is at the start of the variable for now
  • ,pP - Rename the package based on the path of the current buffer
  • ,pI - Introduce a temporary variable

Here are a few screenshots of these actions:

More...

More theft from Padre June 27, 2009

I was pleasantly surprise at the positive response to my last post on Stealing from Padre for Vim—particularly from the Padre developers! Seems they had hoped/planned on separating some of the tools out of the Padre core from the beginning (and many seem to be vimmers).

With their blessing and encouragement, I have pulled the editor independent parts of their PPI::Task tools into its own distribution—PPIx::EditorTools—available now on CPAN. I also adapted the current version of Padre to work wit the external package and released App::EditorTools to provide a command line interface for those editors that need it (i.e., vim). I’ll post another screencast and the Vim scripts needed to integrate it shortly.

More...

Stealing from Padre for Vim June 16, 2009

I’m sure the Padre developers weren’t hoping to have their code absconded for those of us addicted to vim, but tsee’s recent blog post on refactoring with Padre’s lexical variable replace made me jealous—I want that for vim! So hack, hack, hack and voila:

screenshot

More...

License

The contents of this blog are licensed under the Creative Commons “Attribution-Noncommercial-Share Alike 3.0″ license.