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 it at their downloads page. Get it. Install it. Everything goes into:
/Library/PostgreSQL/8.4
Now to install the do_postgres gem, I had to set the $PATH to:
$ export PATH=$PATH:/Library/PostgreSQL/8.4/bin
Now, installing the gem from rubygems.org should work:
$ gem install do_postgres
Remember in OSX where your gems are installed, with or without root access using:
$ gem environment
Debian 5.0 Lenny
I have PosgreSQL 8.3 on my Debian servers, from the repositories. To install the do_postgres gem, you must get the header files for libpq5 (PostgreSQL library):
$ sudo apt-get install libpq_dev
$ sudo gem install do_postgres
Ubuntu 9.10 Karmic Koala
I have PosgreSQL 8.4 on my Ubuntu servers, from the repositories. To install the do_postgres gem, you must get the header files for libpq5 (PostgreSQL library):
$ sudo apt-get install libpq_dev
$ sudo gem install do_postgres
posted by pedro at 5:24 am
& filed under linux, os, ubuntu, apple, ruby, code, debian, vimblog.vim, vimblog, merb, osx, postgres, postgresql, datamapper | No Comments »
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 indexing and serving all the gems - so rather than having two gem indexes, we now have one. As a consequence of this, when you release files to RubyForge you will probably also want to do a “gem push” to get them onto gemcutter and into the main gem index.
Note that you can continue to release gems (and other files) at RubyForge; it’s just that gems won’t utomatically make it into the main gem index.
Yours,
The RubyForge support team
http://rubyforge.org/projects/support/
posted by pedro at 8:29 pm
& filed under tech, ruby, standards, code, rubyforge, open source, merb, gemcutter | No Comments »
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.
posted by pedro at 5:03 pm
& filed under tech, culture, digital-life, standards, code, open source, web 2.0 | No Comments »
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.
posted by pedro at 4:31 pm
& filed under tech, log, linux, code, open source, git, github, unix | No Comments »
August 31st, 2009
“By: Mikio Hirabayashi - 2009-08-31 13:22
BTW, the project site of Tokyo products have been moved onto my own server.
http://1978th.net/
Though it has not been completed yet, I’ll write more English information about Tokyo products.”
So, to get the latest, head there.
posted by pedro at 3:54 pm
& filed under tech | No Comments »
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
posted by pedro at 10:47 pm
& filed under tech, ruby, code, osx | No Comments »
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 consisting of nodes, relationships and properties;
- highly scalable to bilions of nodes/rels/props;
- can be sharded to scale out across multiple machines;
- hi-speed traversals in the node space;
- small footprint (500k jar)
- ACID transactions;
- robust persistence;
- concurrency control;
- API;
- Neo4j.rb, JRuby API;
- Lucene for quering and indexing.
Neo4j is released under a GNU Affero General Public License, so read carefully. There’s a price table for commercial products that includes severall support levels.
posted by pedro at 9:52 pm
& filed under code | No Comments »
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 with extensions, without the need for restarts (updates, etc).
Not to miss this article too: Tokyo Cabinet: Beyond Key-Value Store
Tokyo Cabinet starts here with a nice presentation from its creator, another Japanese developer Mikio Hirabayashi.
Ruby, Perl, Python et_al bindings available.
I tell you, “it’s Big in Japan”
posted by pedro at 2:37 am
& filed under ruby, code, tokyocabinet | No Comments »
June 6th, 2009
I was contacted via Twitter for some support on getting vimblog.vim to work on MacVim, on Mac OSX Leopard. The unique problem is that it must be compiled with Ruby interpreter support. So here is a quick guide to do it, building from Macvim git repository:
# select a folder where to build the aplication on your area:
cd to_your_workingspace_apps_folder
# get (clone) MacVim from its MacVim.git repository:
$ git clone git://repo.or.cz/MacVim.git
$ cd MacVim
$ cd src
# now let us configure it for macvim gui and for +Ruby (I’ll add +Python and +Perl) support:
$./configure --enable-gui=macvim --enable-rubyinterp --enable-perlinterp --enable-pythoninterp
$ make
# Success ? Let’s build the MacVim.app
$ cd MacVim
$ xcodebuild
# Sucess ? Let’s try it…
$ open build/Release/MacVim.app
# now lets copy vimblog to $HOME
$ cp $HOME/Downloads/vimblog.vim $HOME/.vim/plugin
# insert your credentials
# now test the existence of the script. Run MacVim and execute
:B + TAB
# you shoud get code completion for the Blog command.
# get the 10 most recent articles
:Blog rp
if you get problems, before another build, do a:
$ make distclean
Screenshots:
macvim window
building space
posted by pedro at 1:52 pm
& filed under vim, vimblog | 2 Comments »
May 12th, 2009
posted by pedro at 8:09 am
& filed under digital-life, apple, Flickr | No Comments »
April 9th, 2009
I subscrived to some mail publications from Sun Microsystems. After that, one gets the usual validation e-mail.
This one states:
“Dear Sun Community Member,
Thank you for subscribing to the following Sun Microsystems eNewsletter(s)/notifications:
[…]
Sun respects your email privacy and security. In order to start receiving these publications, you must first confirm your subscriptions. Please click on the url below to activate your subscription(s): https://subscriptions.sun.com/sunmailapi/Optin?id=999999999
Thank you for subscribing. We hope you find the information to be valuable.”
The problem here is that the confirmation URL query is nothing but a (*not* garbled) sequential ID. Altering the ID from the link, all the other subscrivers e-mail starts poping-up, and more, they get activated if not done yet.
So, the above “Sun respects your email privacy and security” isn’t quite as should be.
With a simple script, one can get all the Sun.com subscrivers. I can see a spammer doing a:
“Dear Sun.com subscriver, we are partnering with Sun.com to sell you this lovely vacuum cleaner.”
Dear Sun, prevent us from buying lovely vacuum cleaners, fixing these vulnerabilities.
TY.
Update: Less than 24h later, Sun contacted me and fixed (the e-mail adress obfuscation, yet one can still approve other confirmations randomly) it. Well done.
posted by pedro at 9:30 pm
& filed under web | No Comments »
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 blinks, scroll bars, text selection, etc. As a Vim user, I immediatly thought of Vim commands/keybindings in Bespin. Even the simpler and most generally used ones. Not even asking for .vim power scripting ability. And that is a feature any one of us* can write as soon as Bespin coders release a good API. And it is already in the air. Neat.
By the way, look.at.this.mockup.…
The collaborative coding feature isn’t active yet, but if one can give instant editing access to a file for a “check this class”, that’s going to probably replace lots of gists, pasties, etc, on a coder2coder basis.
Code repository access via Dashboard ? Yes please.
I have no doubts, this is going to be a very usable product, for this little I’ve seen. The look’n'feel seems great (even if I had no repeat-key
)
* floss
posted by pedro at 5:46 pm
& filed under web, code | No Comments »
January 15th, 2009
3 or 4 new projects ahead.
One of them will be CouchDB and Merb (no DataMapper, no ActiveRecord). The db schema is modeled by each user and upon criteria decisions.
All of them Git managed, as been doing for the last year.
Served by a Debian based Linux distro, coded under Debian, UNR (my lovely little netbook), and OSX, mainly in Ruby 1.8.7. Production server structure not defined yet but development phase will be Mongrel. May implement a very simple queuing system for a specific need.
Very likely use of AWS (not SimpleDB) for the sake of _simplicity_ .
Editor ? Vim.
None of this is of great interest for the project itself of course. I’ll be queuing 2 or 3 of them, in paralel with the main one. As in everything, time management is almost everything to GTD. Must. repeat. this. always.
posted by pedro at 1:27 am
& filed under tech, web, rss, linux, os, ubuntu, ruby, standards, vim, gvim, s3, ec2, mac osx, debian, mvc, rspec, TODO, git, github, vimblog.vim, vimblog, merb, couchdb, aws | 6 Comments »
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.
posted by pedro at 12:37 am
& filed under code | 1 Comment »
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.
Quite nice.
posted by pedro at 5:59 pm
& filed under code, vim, git, github, gist, vimblog.vim, vimblog | No Comments »
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!
posted by pedro at 1:47 am
& filed under , life | No Comments »
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.
posted by pedro at 7:40 pm
& filed under web, life | No Comments »
October 2nd, 2008
posted by pedro at 1:11 am
& filed under code, git | No Comments »
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.
posted by pedro at 5:54 pm
& filed under life, ruby, code | No Comments »
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: …
posted by pedro at 11:12 pm
& filed under ruby, code, mvc | No Comments »
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.
posted by pedro at 7:46 pm
& filed under ruby, code, camping | 2 Comments »
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…
posted by pedro at 12:52 am
& filed under web, life | No Comments »
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
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.
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
posted by pedro at 2:25 pm
& filed under ruby, code | 2 Comments »
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 ?
posted by pedro at 7:05 am
& filed under code, c | No Comments »
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++
posted by pedro at 3:22 pm
& filed under linux, ruby, shell, code, vi, vim | 2 Comments »
April 7th, 2008
posted by pedro at 10:36 pm
& filed under ruby, code | No Comments »
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
posted by pedro at 12:31 am
& filed under ruby, code, git | No Comments »
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”
posted by pedro at 12:50 am
& filed under code, book, MIT, TOREAD | No Comments »
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
posted by pedro at 12:48 am
& filed under linux, ruby, code, twitter | 1 Comment »
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.
posted by pedro at 2:53 pm
& filed under linux, code, git | 3 Comments »
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
posted by pedro at 1:10 am
& filed under linux, postgres, postgresql, database, dbms | 4 Comments »
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
posted by pedro at 10:32 pm
& filed under ruby, code | No Comments »
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)
posted by pedro at 9:06 pm
& filed under ruby, code | No Comments »
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 who want to look at this language in depth, this guide is invaluable.”
posted by pedro at 10:51 pm
& filed under ruby, code | 1 Comment »
January 13th, 2008
Flash is a Ruby on Rails method to show (mainly warning/error) messages. Camping has no such method, so i implemented an approach for error messages. The thing is, after a post method in the controller, the redirect creates a new instance for the controller, loosing the class instance variables set before.
So, after talking a bit with Zimbatm at #camping, we setup what could be a good solution: to use the @state session variable.
@state.error = ‘The unit is still operational, Dave. But it will fail within seventy-two hours’
The variable is cleared on the View layout method. Flash means just it. Show and clear. The layout code includes:
div(:class => 'error') { p @state.error.to_s; @state.error = ''; } unless @state.error.blank?
and the CSS .error class wraps the message inside a lightred box with a nice solid red border (say RoR?).
posted by pedro at 7:56 pm
& filed under ruby, camping | 4 Comments »