-
Network manager seems to block LAN access (wireless)
I’ve been unable to access my desktop from other devices connected to the LAN. At first I thought it may be the router or the modem, but just realized that simply restarting network-manager fixes things.
sudo /etc/init.d/network-manager restart
-
Mysql index optimization
I’ll explain by example. Say you have a table with these three columns:
org_id domain_id user_id
Say you have an index based on those three columns with the particular order:
index: org_id, domain_id, user_id
If you were to run the following queries, your query would use an index. Note that you don’t have to use all three columns for the index to be used, but your query does have to reference the columns in the same order as your index.
where org_id = ? and domain_id = ? and user_id ? where org_id = ?
However, if you do the following query, you would not be so lucky, as it does not follow the order of your index.
where domain_id = ?
For this query, you would create an index for only domain_id. Also note, you don’t have to create an index when making queries with only org_id as that is already taken care of by the first index above.
-
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!
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.
