Father, husband, and software developer. I'm building web applications since 1994 for a living and I love it.
Rubyist, Rails developer since 2006, believer of Agile Development and Lean startups, NoSQL enthusiast.
Born in Caracas - Venezuela, living in New York.
More than one year ago, I created a very simple script that enable Sublime Text 2 to automatically check the syntax of ruby files when they are saved
Three months ago I finally found the time to convert that script into my first Sublime Text 2 plugin: the RubyCheckOnSave plugin.
To remove all gems from a gemset you use the gemset empty command:
$ rvm gemset empty <my_gemset_name>
And to remove the gems from default gemset, you must supply an empty string as the gemset name:
$ rvm gemset empty ""
cUrl is a simple and powerful tool to test RESTful APIs, but sometimes the output could be messy, specially when the response is a long JSON.
To improve the output readability, I’m using cUrl with jsontool (a node.js script).
After you install it:
$ npm install -g jsontool
Then pipe the cUrl output to jsontool
$ curl -is http://search.twitter.com/search.json\?q\=foo | json -i
Below an example of the output
You need to remove the submodule and re-add the files into the main repo.
Edit the .gitmodules and .git/config files and remove the lines that specify the submodule, then;
git rm --cached path/to/submodule # delete reference to submodule HEAD (no trailing slash) rm -rf path/to/submodule/.git git add path/to/submodule # add files instead of commit reference git commit -m "remove submodule"
Today I tried to deploy to heroku a new version of an application (that not has been deployed in several months):
git push heroku master
but I got the following error:
Permission denied (publickey). fatal: The remote end hung up unexpectedly
The weird part is that I can deploy other 3 apps without problem, that means that my public SSH key is properly stored on Heroku.
If the Heroku api is experiencing downtime, you will get this error when you try to push. So, I checked https://status.heroku.com/ and everything seemed to be fine on Heroku’s end.
Then I checked my git remotes, and my problem was that the remote heroku repository was corrupted. I refreshed it as follows:
git remote -v
Then removed the heroku one that is wrong:
git remote rm heroku
Then added the new one
git remote add heroku git@heroku.com:myapp.git
I have an Enumarable of tokens, and I need to sort them descending by the last_access attribute, but for some objects this attribute could be nil. One OOP approach to do it, is defining the <=> method (Comparable) in the Token class:
class Token
include Comparable
define <=> other
...
end
end
Then I’ll only need to call tokens.sort. But I’m not ready to change the behavior of the Token class in that way, instead of that I prefer to follow an approach that don’t have side effects. So, an easy hack is to use an immediate-if like this:
tokens.sort{|a,b|
(a.last_access && b.last_access) ?
a.last_access <=> b.last_access :
(a.last_access ? 1 : -1)
}.reverse!
We have a db collection that is around 30 million documents, and I need to trim it down, to only keeping the documents created on the last month.
One approach would be use the remove command with a condition on the created_at field (the collection already have an index on this field):
db.my_collection.remove({created_at: {$lte: new Date("11/01/2012")}});
But this approach will be very slow, instead of that, a better way to do it is rename the current collection (for instance to “old_collection”) using renameCollection. Then performing a query-and-insert from the “old_collection” into “my_collection”:
db.my_collection.renameCollection("old_collection");
db.createCollection("my_collection");
db.my_collection.createIndex(...); // recreate the indexes for the collection
// copy docs from old collection into the new collection
db.old_collection.find(
{created_at: {$gte: new Date("11/01/2012")}
).sort({_id: -1}).forEach(
function(row) { db.my_collection.insert(row); }
);
// drop old collection
db.old_collection.drop();
This approach is typically faster than running a bunch of removes on your data
We live in a world where there is more and more information, and less and less meaning
First you set up your staging app following the Heroku’s guide for Managing Multiple Environments for an App
Then edit the config/environments/staging.rb:
#config/environments/staging.rb
MyApp::Application.configure do
# Basic authentication
config.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "My App") do |u, p|
[u, p] == [ENV['HTTP_USER'], ENV['HTTP_PASSWORD']]
end
...
And finally set the config vars:
heroku config:add HTTP_USER='foo' HTTP_PASSWORD='bar' -a myapp-staging
Interesting move, … maybe the only possible move for Text Mate
If you run the “classic” rake -T, only the tasks with descriptions will be appear, for instance:
$ rake -T db
Will display something like:
rake db:create # Create the database from config/database.yml for the current Rails.env (use db:create:all to create all dbs in the config) rake db:drop # Drops the database for the current Rails.env (use db:drop:all to drop all databases) rake db:fixtures:load # Load fixtures into the current environment's database. rake db:migrate # Migrate the database (options: VERSION=x, VERBOSE=false). rake db:migrate:status # Display status of migrations rake db:rollback # Rolls the schema back to the previous version (specify steps w/ STEP=n). rake db:schema:dump # Create a db/schema.rb file that can be portably used against any DB supported by AR rake db:schema:load # Load a schema.rb file into the database rake db:seed # Load the seed data from db/seeds.rb rake db:setup # Create the database, load the schema, and initialize with the seed data (use db:reset to also drop the db first) rake db:structure:dump # Dump the database structure to db/structure.sql. Specify another file with DB_STRUCTURE=db/my_structure.sql rake db:version # Retrieves the current schema version number
But the rake task db:test:prepare is not listed. If you want to list all the tasks, no matter if have a description or not, use this:
$ rake -P
And if you want to avoid the noise, use the following to show the names of all Rake tasks:
$ rake -P | grep rake
If in your specs you have something like this:
it "should be bar" do foo.should == 'bar' something_else end
The ruby -w command will throw the following warning:
warning: useless use of == in void context
The way to avoid this is using this:
foo.should eql('bar')
Or:
foo.should be == 'bar'
Or move the statement
foo.should == 'bar'
so that it’s the last line inside the it block
I’m starting to work on a gem for Singly API that uses multi_json. The tests for the gem worked in 1.9.2 and 1.9.3 but I got the following runtime error in 1.8.7:
missing dependency for FaradayMiddleware::ParseJson: no such file to load -- json
I have been using 1.9.3 more and more lately and I forgot that json was added to the stdlib in 1.9. So that’s why it works in 1.9.x. while in 1.8.7 I need to require a supporting library like yajl.
One of most important thing about startups is that you can collect usage metrics in real time. However, being able to make decisions with this data is not easy. It’s important to understand how to collect and use these metrics, and develop a decision-making framework for startup development. The framework should be based on goals that are measured through discrete users or startup events that have either user or business value.
Dave McClure has been talking about startup metrics since 2009. The first time I saw his talk was during TechStars NYC class of summer 2011.
McClure define five main ways to bucket the events you’re measuring: Acquisition, Activation, Retention, Referral, Revenue (AARRR => the pirate reference)
In Scribd there is a good introduction about stock & options for tech entrepreneur or startup employee
(Also there is a kindle version available in amazon)
Thanks to the combination of smartphone proliferation, the app store distribution model, FB Open Graph integration and Twitter, we are seeing mobile apps reach incredible metrics very fast - particularly in daily installs and sign ups.
It’s has me thinking about a number of things:
FB Open…
If you’re like me, a fan of rebasing local work before publishing, maybe you receive this error:
"interactive rebase already started"
This happens when you abort in the middle of a rebase.
The way to fix it is using:
git rebase -i --abort
Father, husband, and software developer. I'm building web applications since 1994 for a living and I love it.
Rubyist, Rails developer since 2006, believer of Agile Development and Lean startups, NoSQL enthusiast.
I'm currently co-founder and CTO at Piictu.com.
Born in Caracas - Venezuela, living in New York.
Piictu is a free photo-sharing mobile app. Users are encouraged to capture an image on their phone and share it to a subject-appropriate "stream" (or album).
All streams are public, and users are encouraged to reply to a subject with topical pictures creating a photo-conversation. Topics for Piictu streams range widely and feature challenges, games, memes, tutorials, and status updates.
I'm responsible for all aspects of overall technology vision and architecture and backend lead developer : REST API (Ruby on Rails), Heroku, OAuth2, MongoDB, Redis, Amazon s3, Amazon CloudFront, ...
Senior Lecturer of Web Application Development at Computer Sciences School, Faculty of Science
has_many :developers (http://hasmanydevelopers.com) is a workshop specialized in develop Web and Mobile Applications.
We are expert Ruby on Rails developers and NOSQL enthusiasts.
We build Web Applications for Venezuelan market. We are expert Ruby on Rails developers.
We use Ruby on Rails and Agile development, to deliver swift and on-budget results.
Lecturer of Data Communication and Local Area Networks at Computer Sciences School, Faculty of Science, UCV
Develop a web application (the first one in the Venezuelan Oil & Gas industry) to analyze the daily production of barrels of liquefied gas, using the Oracle Web Server
Coordinate and develop the Car Insurance module for Seguros Caracas (Liberty Mutual).
Using Oracle CASE and Oracle Development Suite