Archive for the 'code' Category
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)
posted by pedro mg at 9:24 pm
& filed under ruby, code, github | No Comments »
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.
posted by pedro mg at 5:33 pm
& filed under tech, web, code, codebits | No Comments »
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¶m2=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¶m2=&offset=3
(blogged from Vim)
posted by pedro mg at 1:53 am
& filed under web, ruby, code | No Comments »
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 | […]
posted by pedro mg at 9:06 pm
& filed under tech, code, c, unix | No Comments »
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 […]
posted by pedro mg at 6:38 pm
& filed under ruby, code, merb, datamapper | No Comments »
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 […]
posted by pedro mg at 11:15 am
& filed under tech, apple, ruby, code, git, github, gist, osx, unix, postgres, postgresql, datamapper, database, dbms | 7 Comments »
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 […]
posted by pedro mg at 5:24 am
& filed under linux, os, ubuntu, apple, ruby, code, debian, vimblog.vim, vimblog, merb, osx, postgres, postgresql, datamapper | 3 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 […]
posted by pedro mg 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 mg 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 mg at 4:31 pm
& filed under tech, log, linux, code, open source, git, github, unix | 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 mg 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 […]
posted by pedro mg 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 […]
posted by pedro mg at 2:37 am
& filed under ruby, code, tokyocabinet | 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 […]
posted by pedro mg at 5:46 pm
& filed under web, code | No 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 mg 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 […]
posted by pedro mg at 5:59 pm
& filed under code, vim, git, github, gist, vimblog.vim, vimblog | No Comments »
October 2nd, 2008
Updated my github.com source code repo account.
posted by pedro mg 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 […]
posted by pedro mg 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 mg 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 | […]
posted by pedro mg at 7:46 pm
& filed under ruby, code, camping | 2 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 […]
posted by pedro mg 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 mg 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. […]
posted by pedro mg at 3:22 pm
& filed under linux, ruby, shell, code, vi, vim | 2 Comments »
April 7th, 2008
self note for a nice read: Introduction to the Rubinius compiler
posted by pedro mg 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 […]
posted by pedro mg 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 […]
posted by pedro mg 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 mg 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 […]
posted by pedro mg at 2:53 pm
& filed under linux, code, git | 3 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 […]
posted by pedro mg 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 mg 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 […]
posted by pedro mg at 10:51 pm
& filed under ruby, code | 1 Comment »
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 […]
posted by pedro mg at 4:32 am
& filed under ruby, code, camping | 2 Comments »
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:
$ […]
posted by pedro mg at 12:21 am
& filed under ruby, code | No Comments »
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 […]
posted by pedro mg at 8:27 am
& filed under tech, code, git | 3 Comments »
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 […]
posted by pedro mg at 1:39 am
& filed under google, gmail, mail, ruby, code | 7 Comments »