Archive for the 'Mac OS X' Category

Pretty Print Code script (hack)

March 1, 2007

The hack presented below has been developed on a MAC OS X. It uses the TOhtml function of the Vim Editor (i use Version 7.0). It runs in HTML Mode only.

f=$1vim -f +”syn on” +”run! syntax/2html.vim” +”wq” +”q” $f

sed -n ‘/<pre>/,/<\\/pre>/p’ $f.html | sed ’s~<pre>~<pre style=”margin: 1.5em 0px; padding: 10px 10px 10px 10px; [...]

some more testing of a script that will do the code formatting

February 28, 2007

I have hacked a script which converts the selected text in Ecto to the following formatted text.

while (<>) {
$text .= $_;
}
# procedural usage
my $html = textile($text);
#print $html; <—- this would get printed in a dialog box
open ( FILE, “>$entryfile” ) or die;
print FILE $html;
close FILE;
[Update: If you look carefully, syntax highliting done by the [...]

Automatic hyperlinking to wikipedia and others using ecto scripting

February 28, 2007

Ecto is a feature-rich desktop blogging client for Mac OS X and Windows, supporting a wide range of weblog systems, such as Drupal. It allows me to plug-in my own scripts writing in programming languages such as ruby, perl, Bash and i suppose python also.

This feature allows for some nifty stuff such as filtering the [...]

Publishing code on this blog through Ecto

February 28, 2007

Background: All attempts to publish some simple source code on this blog failed. Be it directly on WP or through Ecto. PRE and CODE tags made no difference. How many tags I might have to manually change, i do not know. But < and \ we certainly disappearing !
And so now, I run the [...]

ecto and Markdown

February 28, 2007

#!/usr/bin/env ruby
# Markdown’ise things.
# Take Markdown markup on STDIN, and output HTML to STDOUT
require ‘rubygems’
require ‘bluecloth’
#print (BlueCloth.new STDIN.read).to_html
file = ARGV[0];
text = File.open(file,”r”).readlines.join;
html = (BlueCloth.new text).to_html
File.open(file, “w”).puts html;

I must first admit that since ecto supports a WYSIWYG editor therefore a script that does textile or markdown filtering does not make much sense. Also, there is the [...]

Vim and Ruby

February 28, 2007

Have been doing some work of late using my favorite editor VIM. A life-changing article or series of tips is this page. Using Vim with and a programming language like Ruby, makes a very powerful combination.
So I do part of my work in Vim itself, using its powerful regular expressions and other features. Once [...]

Old Stuff

October 2, 2005

Oct, 2005
Mediawiki and Textile are great!
Have been exploring Ruby on Rails. Looks promising. Certainly beats the crap outof doing web apps with JSP, Struts and J2EE.
You might see me doing something with ROR.
At long last, the fine folks at Apple have released J2SE 1.5 for MAC OS X 10.4. I wrote a program to [...]