Archive for the 'code' Category

monstar.rb update

April 24th, 2013

New update on the monstar.rb ruby script to monitor and restart scripts/apps upon file ctime changes.
Now a -e –exec switch allows any system script/app to be launched via Process.spawn(SCRIPT)
PID processes are killed via INT SIGNAL.
More on github monstar.rb repository.
(blogged from Vim)


Codebits 2012

September 12th, 2012

A new year, a new Codebits event by the incredible Sapo Team.
I will be attending the event once again in November’12,
now that the participation was accepted for the event.
The venue is amazing, see by yourself.
Its about code, programming, web, internet, networking.


Manage URI Query params in Ruby

February 10th, 2012

How to programatically remove a Query parameter from an URI String in Ruby.
For the following URI:
http://example.com/resource?param1=1&param2=2&offset=3
If one wants to remove the “offset” parameter, the following may help.

EDIT: if a left side only param exists, it will be removed. Something like param2 in:
http://example.com/resource?param1=1&param2=&offset=3
(blogged from Vim)


the R from K&R

October 13th, 2011

“Ritchie was best known as the creator of the C programming language and a key developer of the Unix operating system, and as co-author of the definitive book on C, The C Programming Language, commonly referred to as K&R (in reference to the authors Kernighan and Ritchie).”
Farewell Dennis Ritchie, your work changed my life.
C | […]


DataMapper update_or_create

October 13th, 2010

Source code: git repository at github
DataMapper has a defined method named first_or_create, very explicit name, that takes a condition and attributes as params. Its source code defined in dm-core-1.0.2/lib/dm-core/model.rb is:
def first_or_create(conditions = {}, attributes = {})
  first(conditions) || create(conditions.merge(attributes))
end
What is does is simply find the first resource by conditions, or create a new resource with the […]


install PostgreSQL in Mac OSX via Homebrew

March 10th, 2010

Apple OSX Snow Leopard
System Version: Mac OS X 10.6.2
Kernel Version: Darwin 10.2.0
Install notes for PosgreSQL 8.4 install using the great
Homebrew by Adam Vandenberg.
Run the author’s installation script, and that’s it. Try:
$ brew help
$ brew search postgresql
$ brew install postgresql
==> Summary
/usr/local/Cellar/postgresql/8.4.2: 2297 files, 31M, built in 3.3 minutes
$ brew info postgresql
postgresql 8.4.2
My advice ? Use Homebrew. True UNIX […]


install do_postgres on OSX Leopard

March 3rd, 2010

Install notes for Datamapper do_postgres driver ruby gem on severall operating systems:
Apple OSX Snow Leopard
System Version: Mac OS X 10.6.2
Kernel Version: Darwin 10.2.0
(No Macports; No Homebrew)
PosgreSQL 8.4
I wanted to have PosgreSQL server working on the mac so that development is easier.
There is a .dmg package from the guys at EnterpriseDB that is a single click install. Check […]


Gemcutter indexing ruby gems

November 23rd, 2009

Date: Sat, 21 Nov 2009 22:15:15 -0500 (EST)
From: noreply@rubyforge.org
To: me@mydomain.com
Subject: [RubyForge] Gem index has been shut down
Hello -
You’re receiving this email because you’re a RubyForge project admin and a recent change robably affects you.
A few days ago we repointed gems.rubyforge.org to the gemcutter.org box. This means that Nick Quaranto’s excellent gemcutter app is now […]


next week… Codebits

November 23rd, 2009

its next week, yet fun starts much sooner; conference; talks; code; lisbon; 3day => codebits
Just like last year a lot of hacks and experiments are expected.
Kudos to the SAPO team, the organisers, to build up such an impressive event.


Revision Control Software workshop

November 23rd, 2009

Last saturday the local Linux group, PortoLinux had a meeting at the engineering faculty of Porto University to discuss about usage of diferent SCM’s.
Main systems covered, centralized vs distributed:
- Subversion
- Git
It was a good tech event, spent a good time there.
Some photos here.


sdef - scripting definition files

August 24th, 2009

Scripting definition files (sdefs) are XML files that describe everything
about an application scripting interface: terminology, implementation
information, and complete documentation. Applications may incorporate
them to define their own scriptability, and scripting clients such as
AppleScript and Scripting Bridge read them to determine what operations
an application supports.
man sdef


Graph Database Neo4j

August 21st, 2009

“Neo4j is a graph database. It is an embedded, disk-based, fully transactional Java persistence engine that stores data structured in graphs rather than in tables. A graph (mathematical lingo for a network) is a flexible data structure that allows a more agile and rapid style of development.”
From the site:

graph-oriented model for flexible data representation;
graph network […]


tokyo cabinet

July 23rd, 2009

Interesting article with links from Ilya Grigorik about Tokyo Cabinet, Tokyo Tyrant (remote network access to the DB, via a rest_client p.ex.) and the “magnifique” Lua programming language, integrated for the ease of creation of user _designed functions into the server. A question I asked is the ability, or lack, of dinamically feed the server […]


Mozilla Bespin

February 19th, 2009

“Bespin proposes an open extensible web-based framework for code editing that aims to increase developer productivity, enable compelling user experiences, and promote the use of open standards.”
one can read this here.
Bespin’s initial prototype includes support for very basic features, but one can easily notice its power. Its all drawn in the canvas, every character, cursor […]


CouchDB Implementation

November 21st, 2008

… just marking this CouchDB Implementation technical post from Ricky Ho here to read tomorrow while hacking on my new Aspire One. Basically, Ricky’s posts are almost all a must_read.


Gist from Vim

November 20th, 2008

Some things are pure smartness: Gist integrated with Vim by the use of vimscript for gist by Yasuhiro Matsumoto.
For reference:
:[from],[to] Gist -p # post lines (from, to) to gist privatelly
:[from],[to] Gist # post lines (from, to) to public gist
:Gist [xxxxx] # edit […]


github repo’s update

October 2nd, 2008

Updated my github.com source code repo account.


Disparition de Guy Decoux

September 25th, 2008

This is a small post to remember a great ruby programmer.
Ruby France announced Guy Decoux “disparition”:
“He was part of the generation of developers who switched from Perl to Ruby in the 90s. While his mastering of Perl was already great, his knowledge about Ruby was so deep and impressive that a lot of Rubyists would […]


fragment identifiers

June 12th, 2008

Q: how in Routes/Markaby do we implement fragment identifiers # as in www.foo.bar/pedro#here, for named anchor jumps ?
H(int): is it necessary to parse the controller ?
H(int): can a regexp solve it ? ‘/foo/(\w+)#(\w+)’ doesn’t…
A: …


AR::migrations

June 9th, 2008

ActiveRecord database schema migration info is stored in the main database, so that if one needs to manually hack a migration (fastforward/rewind), just update TABLENAME_schema_infos column ‘version’ to a new value and manually change your schema. Next ‘boot’ may generate (or not) new migrations.
riverside=# select * from foobar_schema_infos;
id | version
—+———
1 | […]


class Monstar

June 5th, 2008

I recently had to move from using FastCGI on Camping Ruby framework, to sweet Mongrel because of getting too much 500 HTTP errors under some load tests. Yes irc::zimbatm, me too.
When on FastCGI behing Lighttpd, upon each request, the code is loaded so after changing its source, it gets updated.
Now, under development, Mongrel(s), behind the […]


2008 ACM-ICPC Programming Results

April 13th, 2008

Draft configuration for the programming environment at 2008 ACM-ICPC World Finals.
“Pascal has been dropped as a World Finals Language”… I miss Delphi (Object Pascal)
Look at the final results.
Now lets see 2007 standings.
Geo pattern ?


blog with Vim script

April 10th, 2008

… after severall exchanged emails between me and Andrei Thorp about the Vim blogging ruby script, we made some changes. So instead of the initial test for Vim compiled with +ruby message s:ErrMsg, we now have an echo.
Andrei’s git (yep, they are git fans too, git rocks!) commit was calling another Vim from his machine. […]


Rubinius documentation

April 7th, 2008

self note for a nice read: Introduction to the Rubinius compiler


Shoes.rb on Github

April 4th, 2008

_why posted in Shoes mailinglist that he will be moving source code to Github.com. Since I am using Git for some months, this is good news.
In short, Shoes.rb repository:
http://github.com/why/shoes
You can clone the repository with:
git clone git://github.com/why/shoes.git
Ditz, (“a simple, light-weight distributed issue tracker designed to work with distributed version control systems like darcs and git”) will […]


the spirit that lives in the computer

April 2nd, 2008

“We are about to study the idea of a computational process. Computational processes are abstract beings that inhabit computers. As they evolve, processes manipulate other abstract things called data. The evolution of a process is directed by a pattern of rules called a program. People create programs to direct processes. In effect, we conjure the […]


Twittershoes: programming in Shoes.rb

February 22nd, 2008

I have to share this piece of code, wich results look indeed nice. You’ll see in the next blog post…

def string_alert
  c = (LIMIT-@iSay.text.length)
  @remaining.style :stroke => “#3276BA”
  c > 10 ? (@remaining.style :stroke => orange) : (@remaining.style :stroke => red) if (c < 21)
  c > 0 ? “#{c.to_s} chars” : “Too Long!”
end

[update]: Twittershoes.rb is born: screenshot here


first repo at github.com

February 15th, 2008

… just got my github.com invitation and proceeded to the registration.
They say its free while in Beta. Hosted in Engine Yard.
I created my first repo there, and the design seems clear, simple, effective.
Info is presented clearly, and i enjoyed the way they went after the creation of my repo, showing “Next Steps”. Nice.
I’ll work there […]


JSON Ruby and Smallr API

February 3rd, 2008

Nuno’s smallr.net API talks JSON. So what about accessing it with Ruby ?
Well, quite easy thanks to Florian’s JSON implementation for Ruby. So:
$ sudo gem install json_pure
Now, just need some attention on the use of the address / (slash) just after json and before the query, or you’ll get a HTTP 301 Status Code.
Code follows:
require […]


on URI Ruby escaping

February 3rd, 2008

URI.escape method with no options doesn’t provide a trully good escape, and i just noticed it upon the need to access an API.

url = ‘http://www.ruby-lang.org’
bad = URI.escape(url)
good = URI.escape(url, Regexp.new(”[^#{URI::PATTERN::UNRESERVED}]”))

The difference is:

bad => “http://www.ruby-lang.org”
good => “http%3A%2F%2Fwww.ruby-lang.org”

(via snippets.dzone => Matt Zukowski)


The Ruby Programming Language

January 29th, 2008

… next buy.
“Bestselling author David Flanagan teams up with Ruby creator Yukihiro “Matz” Matsumoto and writer/cartoonist/programmer why the lucky stiff to bring you the authoritative guide to Ruby. Covering versions 1.9 and 1.8, this book helps you learn Ruby’s lexical structure, primary expressions, conditionals, syntax, classes, the data it manipulates, and more. For experienced programmers […]


Camping on IRB

December 22nd, 2007

IRB is a great tool. What about testing parts of a Camping app in IRB (meaning App::Models module) ? Just require the app, but do not forget to establish the (in case of using it) ActiveRecord connection, that problably is specified in dispatch.rb
Try this, using _Why’s Blog webapp example:

$ cd /path/to/blog/app
$ irb
irb(main):001:0> require ‘rubygems’
irb(main):002:0> require […]


ActiveRecord connection adapters

December 22nd, 2007

…because of Camping::Models I’m using ActiveRecord Ruby implementation gem. Because source code is pretty well documented I maintain an opened xterm to check how things are done. Since I’m not using SQLite but PostgreSQL, i had to dig for the other parameters for the connection and I noticed AR has now connectors for severall DMBS:
$ […]


… on git

December 9th, 2007

Melo will be focusing on git
Once you get used to git, you won’t be needing “anything else” to maintain your code. Git is gaining more and more traction, now that bigger (distributed) projects (or parts of them) are running away from other scm’s into this one (Gnome ?, Kde, …). CVS, SVN user base is […]


msg upload to gmail ruby class (imap)

December 4th, 2007

… moving to Google Hosted (Google Apps), there was the need to upload some thousands of e-mail messages. Since they were (mt) MediaTemple Berkeley mbox stores, i scp’d them locally (backup) and them imported them into Evolution local folders.
The problem was the copy/move to the google hosted imap mail server. Evolution couldn’t finish the task […]