May 2012
7 posts
8 tags
Mongoid recursively embedding
This is a note for myself for a project I am actually working on that I thought could be useful to share :)
More info here.
CYCLIC RELATIONS on MONGODB WITH MONGOID
A document can recursively embed itself using recursively_embeds_many, which provides accessors for the parent and children.
class Tag
include Mongoid::Document
recursively_embeds_many
field :name
end
programming =...
4 tags
Updating embedded child objects when the parent...
Mongoid has added a tag which automatically makes callbacks for embedded child objects when the parent object is saved.
You can find it at the end of the mongoid documentation on embedding.
class Post include Mongoid::Document include Mongoid::Timestamps include Mongoid::Paranoia embeds_many :comments, cascade_callbacks: true accepts_nested_attributes_for :comments end
1 tag
I am truly free only when all human beings, men and women, are equally free. The...
– Mikhail Bakunin - Bakunin on Anarchy
1 tag
Do I contradict myself? Very well, then I contradict myself, I am large, I...
– Whitman
4 tags
I find fascinating how people protect the right of the richest for fear of...
– my self :)
3 tags
If you go where everybody else is you might just end up doing the same...
– myself :)
4 tags
Nested hash in ruby
Ever wondered how to create nested hash in ruby?
Here it is:
1.9.3p125 :001 > a = Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) }
=> {}
1.9.3p125 :002 > a[2][1] = 2
=> 2
1.9.3p125 :003 > a[2][2][3] = 2
=> 2
1.9.3p125 :004 > a[2][2][4] = 5
=> 5
1.9.3p125 :005 > a[3][1][1][1] = 7
=> 7
1.9.3p125 :006 > a
=> {2=>{1=>2,...
March 2012
2 posts
6 tags
Devise + Mongoid + Cancan
I have thought a while about making a summary post about configuring devise + mongoid + cancan for creating accounts and implementing authentication in a rails app.
First of all there are various guides that you can use to get you started. All of them can give you a different insight on the technology and a different perspective and what is needed to accomplish whatever you have in mind :).
So...
otacon22 asked: Hai fatto parte del POuL un po' di tempo fa? :-)
February 2012
1 post
7 tags
How to load a feed with Google Feed API and JQuery
Here is a quick and dirty way to load a xml feed with Google Feed API with Jquery. Enjoy!! :)
First step include the necessary external calls:
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js”</script>
<script type=”text/javascript” src=”https://www.google.com/jsapi”></script>
Second step your javascript...
November 2011
1 post
4 tags
Quick and dirty search in Rails
Ever wondered how to quick have a search function in your rails app?
Here is a super quick and maybe a lil dirty way to achieve so.
First step:
The view
<p><%= form_tag("/searches", :method => "get") do %>
<%= text_field_tag :keywords, params[:keywords] %> </p>
<p> <%= submit_tag("Search") %>
<% end %>
...
October 2011
1 post
4 tags
Ruby headaches pills
If:
script/rails generate controller Hello
Is failing, try to remember that you have probably installed more than one version of rails in your history, so you might need to call:
rvm use 1.9.1 —default :)
September 2011
6 posts
3 tags
The future is distributed!
5 tags
Hire the hackers!
3 tags
3 tags
Home abroad →
I still treasure my memories of two weeks spent in Buenos Aires almost 3 years ago, and this article has brought all of them back again :)
4 tags
Work smarter, play harder
– Never got why we have to work hard… ;)
9 tags
Schmidt says definitively: the next generation of leaders and startups to emerge...
– Reinvent the future, everything else will follow.
August 2011
3 posts
3 tags
8 tags
Creative destruction
From Capitalism, Socialism and Democracy (New York: Harper, 1975) [orig. pub. 1942] by Joseph A. Schumpeter, pp. 82-85:
Capitalism, then, is by nature a form or method of economic change and not only never is but never can be stationary. And this evolutionary character of the capitalist process is not merely due to the fact that...
2 tags
Quick start on Amazon AWS.
How exciting! Amazon has started to offer free tier 1 year account to their AWS services. So why not try the services out with a small project or a new web app?
The Ubuntu EC2 starter guide gives you some hints and tips to using Ubuntu’s official images on Amazon EC2.
To summarize:
1. Create your account on Amazon, if you don’t have one already. Go to http://aws.amazon.com, and...
July 2011
4 posts
3 tags
5 tags
Former Google CIO: LimeWire Pirates Were iTunes’... →
5 tags
7 tags
Skate this! →
May 2011
12 posts
7 tags
Every pirate wants to be an admiral.
7 tags
On the nature of Innovation
Innovation is in a way at the hearth of the pirate’s spirit and probably the first weapon against competitors. Finding something totally new, grasp a revolutionary idea and taking it into practice, it is something entrepreneurs and companies alike are often obsessed with.
It is often believed that innovation goes hand in hand with creativity, and the quality of being able to find unusual, or...
6 tags
Pirates are essential to innovation
All great inventions, all great ideas started with a leap of faith, a grain of foolishness maybe, and some stubbornness to sustain a project despite everyone believing the opposite.
All great inventions, if they are truly extraordinary, they change the world as it was known before, by re-defying space, time, and above all laws and models.
All great inventions need pirates.
Take the airplane...
4 tags
A modern Pirate.
The English term Pirate is derived from the latin word Pirata and from the greek word πειρατής” (peiratēs), “brigand”,in turn from “πειράομαι” (peiráomai), “attempt”, which as well comes from “πεῖρα” (peîra), “attempt, experience”. Nor the word attempt or experience can be found in the modern image that we have of pirates. Nor...
A quick intro
Just what it says…