-
On Steve Jobs
As I read about Steve Jobs, I see a person who envisioned amazing things whose passion and drive was unstoppable, amassing a following akin to a religious order. To the benefit of humanity, he materialized his vision, sharing the results with millions. Unfortunately, not all touched by Jobs was beautifully executed.
He entered the dog-eat-dog environment of a capitalist society –adapt or become extinct. He –almost inescapably, yet completely voluntarily– he adapted. So came the scandal regarding backdating employee stock options and outsourcing manufacturing jobs to cheap labor in China. He was passionate and confident, but sadly and understandably human, a humongous ego often accompanies such people, such as taking credit for subordinates work, indifferently reversion opinions after calling them “shit”, and crudely “motivating” employees –sometimes to tears.
In summary, here’s a visionary who gambled all and choose, in good faith, the overall good, though again understandably human. His passionate eloquence also illustrates for me, the power of words to invite people to dream and actually make people believe dreams can come true.
-
Queries using :join in a many to many relationship using :has_many :through
Say you have have a model name Resource and one name Category and you want to specify a many-to-many relationship using Ruby on Rails. For this I’ve chosen the :has_many :trough directive, causing me to create a join model which I call Categorization and respective table.
The trouble I encountered was when I wanted to fetch resources or categories who only have values in the join table (using :include would do just that, include them in my query results), so I had to use :join. First, of all, I’ll show you my models and then present my problem.
Resource model
class Resource < ActiveRecord::Base has_many :categorizations, :dependent => :destroy has_many :categories, :through => :categorizations end
Join model Categorization
class Categorization < ActiveRecord::Base belongs_to :resource belongs_to :category end
Subjects model
class Category < ActiveRecord::Base has_many :categorizations has_many :resources, :through=>:categorizations end
Ok, the issue I encountered is when I create a query where I want to fetch resources that are mentioned in the join table categorizations. The error was due to my confusion between the :joins and :include parameter in a find query, which I hope to clarify here and may be to use to others.
The follwing gives an error, “ActiveRecord::StatementInvalid: Mysql::Error: Unknown table ‘resources’: SELECT resources.* FROM resources categorizations WHERE (categorizations.category_id = 1).”
@resources = Resource.find(:all, :select=>"resources.*", :joins=>:categorizations, :conditions=>["categorizations.category_id = ?", 1])
This is because :joins expects actual text that defines the join relationship. In other words, it’s not smart enough of to know what kind of relationship you want as when using :include (which in this case would only work with :categories rather than :categorizations). You may want a LEFT JOIN or a RIGHT JOIN or OUTER JOIN, etc.
Therefore, to fix this, I simply had to define the relationship, which in this case is a simple JOIN (i.e. INNER JOIN).
@resources = Resource.find(:all, :select=>"resources.*", :joins=>"JOIN categorizations ON resources.id = categorizations.resource_id", :conditions=>["categorizations.resource_id = resources.id AND categorizations.category_id = ?", 1])
-
Adding your own web applet to Avant Window Manager in Debian/Ubuntu
It’s surprisingly simple. No coding knowledge needed, though some image authoring program may come in handy..
The easy to use and handy Avant Window Manager(AWN) includes a web applet that initially gives you the option to add various websites so you can easily access them through your toolbar.
Here’s how to add your own. The applet takes in a configuration file with a list of websites and options. All you need to do is add another website and create or find an svg and a png icon for your button.
In Debian linux, you will find it at /usr/share/avant-window-navigator/applets/webapplet/webapplet-websites.ini. If it’s not there, make sure you have the awn-applets-c-extras package (otherwise do “apt-get install awn-applets-c-extras”) and if still not there you can try to search with this:
dpkg -L awn-applets-c-extras | grep webapplet.websites.ini
Once you identify the config file, you will need an icon for your button, both a svg version and a png version. the png version should preferebly be 22 pixels. Copy both of these to the icons folder that exists in the same location as the configuration file.
Note you’ll need root access for the above and next action. Next add the following to the webapplet.websites.ini, specifiying the names of the icons (don’t include folder “icons”). Note also that it is preferable to use the URL of the mobile view of the website, if it has one. Also, you can specify the height and width in pixels of your web applet.
[FooBar] Name=FooBar Comment=Foo bar is a bogus app URL=http://foo-bar.com/mobile Icon-22=foobar-22.png Icon-svg=foobar.svg Width=1000 Height=500
That’s it enjoy!
-
Kdenlive review
Update (03/01/2012): I’ve recently begun using Cinelerra and while it’s a pain to build/install, I’ve found it more apt for advance video editing. Especially, you can reverse video in it, something that seems it will take a lot of work in Kdenlive. I’ll try to do a post on it in the near future.
As some of you know, Kdenlive is a free and open source video editor. As of lately, I have really enjoyed working with it and am impressed at its feature set. The best part of it is that time line view is quite intuitive. Furthermore, you can do your basic text clips and mask different clips together in interesting ways. One unique thing I found out recently is the ability to create your own masks so for example, you could have a background video of say of some fire and then create a smiley face mask on another video so that the video on top has this fire-filled smiley face (see how to) . Also, there is many audio and video effects you can apply to your clips.
Granted it’s not perfect and you may encounter a bug or two, but for your basic editing and some cool effects/transitions, it’s awesome. I am in the process of exploring it more, but as of now, you can check out some videos I made using kdenlive.
-
Lame Apache error
I was getting this error when starting my apache server
Apache error: pcfg_openfile: unable to check htaccess file, ensure it is readable
This is due to permissions, seems all you have to do is add the execute bit to owner.
chmod 755 foldername
source: http://www.liamdelahunty.com/tips/apache_pcfg_openfile_unable_to_check_htaccess.php
About me
I live in Denver, Colorado and work as a contractor for HAIKU Learning Systems, Inc., an online learning company. I did my Master's in Music Informatics at Indiana University and got a B.A. in Computer Science and Mathematics, with a minor in Music from Carroll College in Helena, Montana.
