Is there a simple way to get image dimensions in Ruby?

As of June 2012, FastImage which “finds the size or type of an image given its uri by fetching as little as needed” is a good option. It works with local images and those on remote servers. An IRB example from the readme: require ‘fastimage’ FastImage.size(“http://stephensykes.com/images/ss.com_x.gif”) => [266, 56] # width, height Standard array assignment … Read more

Assertion not working

You need to run your program with the -ea switch (enable assertions), otherwise no assert instructions will be run by the JVM at all. Depending on asserts is a little dangerous. I suggest you do something like this: public Grid(int size) { size = Math.max(0, size) setLayout(new GridLayout(size, size)); grid = new JButton[size][size]; } Or … Read more

Rails, MySQL and Snow Leopard

I just went through the same pain… here’s what worked for me: Download / install the 64-bit MySQL 5.1.37 from mysql.com run the following commands: sudo gem update –system sudo env ARCHFLAGS=”-arch x86_64″ gem install mysql — –with-mysql-config=/usr/local/mysql/bin/mysql_config I also uninstalled all mysql gems that were floating around from my 10.5 days, that may do … Read more

Python: Unable to Render Tex in Matplotlib

On an Ubunutu 14.04 machine the combination of answers from above worked. I sudo apt-get install the dvipng,texlive-latex-extra, and texlive-fonts-recommended packages and that did the trick: $ sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended Edit: As of Matplotlib 3.2.1, you now also need the package cm-super (see https://github.com/matplotlib/matplotlib/issues/16911) $ sudo apt-get install dvipng texlive-latex-extra texlive-fonts-recommended cm-super