Rudimentary Art of Programming & Development

Promoting Open Source, Always…

Archive for May 2009

Yes! Syntax Highlighting for Mako in TextMate!

with one comment

For the longest time I kept staring at ‘plain text mode’ while editing Mako templates. No Mas!

TextMate bundle for Mako template has existed.

To install:

  • cd ~/Library/Application\ Support/TextMate/Bundles/
  • svn co http://svn.makotemplates.org/contrib/textmate/Mako.tmbundle

After Reloading your bundle, syntax highlighting is available under HTML (Mako).

Reference:


Written by didip

May 31, 2009 at 8:29 am

Posted in mako, pylons, python

Tagged with , ,

HTML Quickie: Long String Overflowing Your Div

with 6 comments

Do you have that problem? I do.

EDIT(05/31/2009): Even better solutions:

Hyphenator.js: http://code.google.com/p/hyphenator/

OR:

General CSS solution:

overflow: scroll

/EDIT

The HTML solution:

use <wbr>. (But you have to figure out yourself where to put the tag)

The IE-specific CSS solution:

word-wrap: break-word

PHP solution:

wordwrap(‘your_very_long_string_here’, 15) // Break after 15 characters

Python solution:

import textwrap

textwrap.fill(‘your_very_long_string_here’, 15) # Break after 15 characters

References:

Written by didip

May 25, 2009 at 5:39 pm

Posted in HTML, css, php, python, wordwrap

Tagged with , , , ,

The Male Programmer Privilege Checklist

without comments

Original Article here: http://lafalafu.com/krc/privilege.html

The article is thoroughly descriptive and I didn’t even realize some of them until I read it.

Written by didip

May 25, 2009 at 3:01 pm

Posted in programming

Tagged with

Pylons Quickie: Mako Output

without comments

By default Mako HTML escapes all output.

To NOT have this behavior, change the setting of TemplateLookup in environment.py.

Resources:

Written by didip

May 24, 2009 at 10:16 am

Posted in pylons, python

Tagged with ,

Pylons Quickie: I want to use distance_of_time_in_words

without comments

distance_of_time_in_words is a useful function that converts boring looking datetime into something more attractive (and SEO optimized) like: 30 seconds ago.

Pylons gain this functionality via WebHelper which blatantly inspired by Rails.

But, out of the box, this functionality does not exists in my templates. To enable it, I need to add this line in helpers.py:

from webhelpers.date import distance_of_time_in_words

Resource:

WebHelpers Documentation

Written by didip

May 17, 2009 at 1:53 pm

Posted in pylons, python, webhelper

Tagged with , ,

Laconica: Open Source Twitter

without comments

There are so many micro-blogging services nowadays. Sooner or later there will be an open source application for it.

And that application is called Laconica. It is written in PHP.

I haven’t try to install it yet, but it sounds fun.

Resource:

The project’s Trac

Written by didip

May 16, 2009 at 11:42 am

SqlAlchemy Quickie: How to use Distinct

without comments

distinct() method is accessible from Query object. The documentation is kind of obscure, so hopefully this post is helpful for others.

Example:

 @classmethod
def get_all_category(cls):
return meta.Session.query(cls.category).distinct().all()

Reference:

SqlAlchemy 04 Documentation about Query object

Written by didip

May 15, 2009 at 8:28 pm

Posted in python, sqlalchemy

Ruby: A lot of 1 Liners

without comments

Written by didip

May 14, 2009 at 12:31 am

Posted in ruby

Tagged with

Pylons Cheat Sheet

without comments

Written by didip

May 13, 2009 at 8:43 pm

Posted in pylons, python

Tagged with ,

Gender Guesser

without comments

Fresh from Hacker News comments,

GenderGuesser is a simple webapp that analyze your essays and guess whether you are a man or a woman.

Written by didip

May 13, 2009 at 6:39 pm

Posted in web application