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 gist xxxxx
:Gist -l # lists my gists
:Gist -k # lits gists from all

I used Paul Dixon’s Paste bin when needed, specially by its simple interface and good highlighting features. Very good. But Gist makes me able to store my gists on my own account. jump to flickr Quite nice.


Mitch Altmann at Codebits

November 17th, 2008

During the three days of Codebits where our minds are focused on hacking code, learning, networking, coding, eating pizza, creating ideas and implementing them, I had the pleasure to meet and talk to Mitch Altman.

Mitch invents and hacks the coolest things.
Here at Make Magazine, you can see how his BrainMachine is built, and using it is quite an experience…

Yet, my favourite one is the Trippy RGB Waves (schematic, video, photos).

Like Mitch said, imagine a Trippy RGB full wall, how cool would it be walking by!


on Paul Graham’s Bad Economy post

October 17th, 2008

Paul Graham’s gluing the recession factor with lack of competition, investor semi-blindness, operating cheaply and time is [always] now. While evidence is a virtue, this is !new.

:note for non-programmers: ‘!’ as an alias for ‘not’

[update]
This slideshare leaked from, as stated, a Sequoia Capital presentation is worth to look at.


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 have been very happy to have the same one.”

Announcement at ruby-talk where we can see lots of appreciation and recognition for Guy’s work.

_why has a wonderfull post and drawing at Hackety.org.
The following paragraph from _why’s post:
“You’ll hear a lot of people say that we didn’t know who he was. That no one met him. But we all read alot of his code. And clearly that was how he wanted us to know him. Think of how that stands in such sharp contrast to the self-advertisement and vanity journalism of the Web today. We knew him, just not in the way we’re used to.”

Guy’s work in ruby-core libs lives inside the machines we daily operate.
Goodbye Guy Decoux.


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 | 1.4
(1 row)

In a self note, forget not to set option :id => false on join tables for has_and_belongs_to_many relations.


god.pt

June 6th, 2008

god.pt is well described here, @ karlus. We and some more fine guys will be focusing on Gathering of Developers in our city, Porto::Portugal::Europe. We’ll be doing presentations (mostly but not only technical ones), debating ideas, working together hopefully on projects, networking and building business (well, one of the first meetings was partially dedicated to push Nuno sysadminin’ skills to start a “pro” hosting company). Barcamp, First Tuesday, TechMeet, we’ll be having a bit of ‘em all.

The starting group talks Python (Nuno), Ruby (me and Mario), media and communication (Carlos), Php (and domain registering savoir-faire ;)Karlus), and guess what: we’re all on Twitter, like godevel is.

The developers part of GOD isn’t restricted to code_monkeys. We speak business, startup’ing, venture capital, economy, talks (long or lightning), beer, unix, languages, hw, sw, media, web, web, web, servers, life, laptops, frameworks, gossip, gadgets, working environments, projects, code, code, scripts, threads, scaling, architectures. We’ll be focusing less on ideas, more on work. Implementations. On doing it.

I look forward a code_day in wich we’ll be coding for ourselves/others under a strong networking environment, during wich lightning-talks will hopefully rise.

More to come soon…
As for now, I’m fighting threads and forks in Ruby…


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 same Lighttpd frontend, need to be restarted upon source code changes in the models, views, controllers or helpers (yet not CSS files, since they are taken care by lighty). Instead of moving to the xterm, kill the process and restart it i decided to automate it.
Since i was disconnected from the webz, I’ve done this script to detect file changes from a pre-specified array of files, monitored under a certain interval in seconds, with an action to start, kill, and restart an app (in my case, a Mongreled Camping web app).

Problem: Threads
Solution: Process::fork

The app load (in this case I load/execute ruby scripts) is done via Process::fork. A new process starts up each time this method is fired up upon a File.open(f, 'r').ctime change:

def load_app
@pid = Process.fork { load(@app) }
end

Before loading up a new updated instance of the app, the previous one must be terminated. Threads behaviour was problematic because of the thread tree termination in time. This is well done, in a safe mode, with Process::kill(signal, pid) and Process::wait(pid) that waits the pid process termination, essential in the case of Mongrel server.

def kill_app
Process.kill("KILL", @pid)
Process.wait(@pid)
end

As one can see jump to flickr in this screenshot the main app process holds on while the child, in this case our Mongrel’ed Camping web app, is terminated and created a new one. jump to flickr Verbose mode to assert its behaviour. Suits this specific need.

This is very usefull to make tests (Test::Unit:TestCase) run automatically upon source changes (will get to an Autotest clone).

Changing from load(@app) to system(@app), one can get any command be executed. ftp, cp, etc…

The script is here do download under a Ruby License.

Usage: monstar [options]
-a, --app SCRIPT.RB,PARAMS,...
-i, --interval VAL
-f, --files FILE,FILE1,...
-h, --help


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. That was not a +ruby vim. So an error was fired upon git commits. Now we fixed it. This is now, vimblog 1.1. Thanks Andrei.

Open Source++


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 be used as an issue tracker. The YAML database file is included in the commits, since it becomes a project source file. Its Ruby coded and produces quite nice HTML pages.

…nice move _why


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 spirits of the computer with our spells.”

“Structure and Interpretation of Computer Programsâ€


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 for this project.


pg_upgradecluster 8.2 main

February 12th, 2008

PostgreSQL 8.3 is here. After apt-get’ing it, the upgrade didn’t move the 8.2 cluster up. Having 8.2 running in a custom port, made 8.3 go use the standard 5432 port.
8.3 created a main cluster.

Check ports:
$ sudo netstat -anput | grep postgres

Check wich configuration files and wich versions are running:
$ ps -Af | grep postgres

pg_upgradecluster when upgrading the existing PostgreSQL cluster, will check ports of the new and old version (check both 8.2 and /etc/postgresql/8.3/main$ grep 'port' postgresql.conf), and make the newer version use the older version’s port number. Then the older version will use an available port number. This keeps the original Port # in use.

Stop and drop the newly created 8.3 main cluster:
$ sudo pg_dropcluster --stop 8.3 main

Time to upgrade the 8.2 main cluster to 8.3
$ sudo pg_upgradecluster 8.2 main

After checking everything is ok we could remove the older cluster:
$ sudo pg_dropcluster --stop 8.2 main

and “apt-get remove” the 8.2 version.

docs:
$ man pg_dropcluster
$ man pg_upgradecluster


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 'rubygems'
require 'net/http'
require 'json/pure'

url = 'http://www.google.pt/search?q=json+ruby'
escaped_url = URI.escape(url, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
call = Net::HTTP.get_response(URI.parse("http://smallr.net/json/?url=#{escaped_url}"))
res = JSON.parse(call.body)

puts res['status'] # ok
puts res['url'] # http://smallr.net/925


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)



You are viewing a mobilized version of this site...
View original page here

How do you rate mobile version of this page?

Mobilized by Mowser Mowser