\_o< ~ Mirmo Dynamics

Rien de grand ne se fit jamais sans enthousiasme.

To content | To menu | To search

Keyword - useless

Entries feed - Comments feed

Thursday 10 July 2008

Rename directories to lowercase

Using a single (and somewhat simple) shell line, you can rename any directory to its lowercase version.

for i in *; do lcase=`echo $i | tr A-Z a-z`; if [ ! -d $lcase ]; then mv $i $lcase; fi; done;

Viva el chell !

Thursday 27 March 2008

ruby: url_to_constant

A small bit of ruby to get a constant from an URL:

require 'uri'
def url_to_constant(url)
	return URI.parse(url).host.gsub(/^www\./, '').capitalize.gsub(/[^a-z][a-z]/i) { |m| m.gsub(/[^a-z]/, '').upcase }.constantize
end

Nothing exceptionnal here, just a pretext to post something.