The goal of efficiency is more slack.

Saturday, June 19, 2010

Blog from the command line

GoogleCL allows you to post to your Blogger blog from the command line. To install:
  1. Install Python gdata libraries. This entails downloading, untarring, and sudo python setup.py
  2. Install GoogleCL. Same as above.
  3. Copy googlecl-0.9.5/build/scripts-2.6/google (version numbers subject to change) to /usr/local/bin or anywhere else in you PATH.
Now you can open a terminal and run a command like:

google blogger post --tags "online, shell" --title "Frist post using GoogleCL" "Can you believe I'm posting this from the command line?"

Or write your post in a text editor, saving it as ~/tmp/post.html, then:

google blogger post --tags "online, shell" --title "Blog from the command line" ~/tmp/post.html

Thursday, June 10, 2010

Writing a TiddlyWiki plugin

It was easier than I thought to write a simple TiddlyWiki plugin. I wanted to create a shortcut for the "Close all" button on the sidebar.
  1. Hack (a backup of) the core TiddlyWiki html or javascript to make it do what you want. Take note of the functions or objects you edited.
  2. Copy the plugin template [TiddlyWiki.org].
  3. Paste the template into a new tiddler in a stock TiddlyWiki html (not the one you edited).
  4. File out the boilerplate stuff like the plugin's name and author.
  5. Override the functions or objects you noted in step 1 by writing code in !Code section of the tiddler.
  6. Add "systemConfig" to the tag field of the tiddler and save the tiddler.
  7. Save changes to the TiddlyWiki and refresh.
For your convenience, here's the plugin template. Be sure to replace SamplePlugin with the name of your plugin.

/***
|''Name''|SamplePlugin|
|''Description''|<...>|
|''Icon''|<...>|
|''Author''|<...>|
|''Contributors''|<...>|
|''Version''|<...>|
|''Date''|<...>|
|''Status''||
|''Source''|<...>|
|''CodeRepository''|<...>|
|''Copyright''|<...>|
|''License''|<...>|
|''CoreVersion''|<...>|
|''Requires''|<...>|
|''Overrides''|<...>|
|''Feedback''|<...>|
|''Documentation''|<...>|
|''Keywords''|<...>|
!Description
<...>
!Notes
<...>
!Usage
{{{
<>
}}}
!!Parameters
<...>
!!Examples
<>
!Configuration Options
<...>
!Revision History
!!v<#.#> ()
* <...>
!To Do
<...>
!Code
***/
//{{{
if(!version.extensions.SamplePlugin) { //# ensure that the plugin is only installed once
version.extensions.SamplePlugin = { installed: true };

if(!config.extensions) { config.extensions = {}; } //# obsolete from v2.4.2

config.extensions.SamplePlugin = {
sampleFunction: function() {
/* ... */
}
};

config.macros.SampleMacro = {
handler: function(place, macroName, params, wikifier, paramString, tiddler) {
/* ... */
}
};

} //# end of "install only once"
//}}}

Wednesday, May 19, 2010

Upgrading X11 Server on Mac OS X 10.5.8 Leopard

Before:
After:
Some programs found in the MacPorts repository use X. If you followed the default directions on the site as I did and decided to use Apple's X instead of MacPort's, your X is outdated and may cause some problems on those MacPorts installed apps. I got the upgrade in an easy-to-use installer by going to http://xquartz.macosforge.org/, clicking on Latest Release, and downloading the dmg (X11-2.5.0.dmg at the time of this writing).

Be warned that an Apple update will clobber this install. Therefore, you should get the latest X from http://xquartz.macosforge.org/ and install it after an Apple update.

git


My gitk (which uses X) stopped working after the update. I'm not sure if it was the update as I forgot if I ever ran it successfully before the update. Fix: I simply went to the git-osx-installer site on Google Code and downloaded the latest installer under Featured downloads on the sidebar.

Wednesday, March 17, 2010

Using Firefox to view man pages on OS X

Prerequisites:

  • Apache web server running
  • perl

Download man2html

man2html
Mac version I used

Install it

cd to the directory containing contents of tarball.
sudo perl install.me

Put man.cgi into local cgi-bin

Mac: cp man.cgi /Library/WebServer/CGI-Executables/

Configure man.cgi

First line:
#!/usr/bin/perl

Around line 126, add paths to your man pages, including programs you've installed (usually in /usr/local/), e.g. I've installed git:

@ManPath = qw(
/usr/share/man
/opt/local/man
/opt/local/share/man
/usr/local/git/share/man
);

Configure Apache

In /etc/apache2/httpd.conf:

<Directory "/Library/WebServer/CGI-Executables">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

Restart the server to reload the httpd.conf.

Configure Firefox

(source: tips4linux.com)

Go to Bookmarks > Organize Bookmarks;
Open a bookmark folder then right-click and chose New Bookmark;
Name the new bookmark man;
In the Location field paste this line:

http://localhost/cgi-bin/man.cgi?section=all&topic=%s

In the Keyword field type man;
Click Add.

Done. Sweet.

To view a man page, just type in the URL bar of Firefox:
man some-command

For example:
man ls

Popular Posts

Recent Posts

Unordered List

Text Widget

Pages

Powered by Blogger.
Scroll To Top