fogbound.net




Fri, 26 Dec 2014

Makering of Physical Digital Stuff

— SjG @ 6:11 pm

I’ve been playing with moving from digital space to physical space. Thus far, I’ve been doing it the easy way — I’ve been building models using OpenSCAD or Moment of Inspiration, and have been relying on Shapeways to perform the actual translation from digital to physical.

First project was to create a stocking-stuffer for Pastafarians. The Flying Spaghetti Monster was modeled in MoI, and printed into plastic by Shapeways. For the “Strong and Flexible Plastic” material, Shapeways uses selective sintering rather than the extruder technology used by most inexpensive desktop 3D printers. This technology allows for printing of larger unsupported shapes, thus my FSM is easily printable using their machines while it would not be with a home 3D printer (probably not impossible, but it would involve printing a lot of extra supports).

Anyway, here’s the FSM printed in purple amidst some whole-wheat penne (created using a commercial wheat extrusion system).
DSC_2043

The next challenge was jewelry. Starting with a sketch, the idea was a ring with a colored pattern. This would involve mating halves, each printed in a different color or material. The sketch was quickly modeled in MoI.

sketch moi

I added only a tiny, tiny tolerance between the two shapes. I created the “cut out” portion of each half using a boolean subtraction of the other half, and then did an overall reduction of one half by a tiny percentage. In retrospect, of course, the approach used to create tolerance was incorrect for a number of reasons. But at the time, I measured up the resultant output file (using Autodesk’s MeshMixer) and it looked like it was good.

meshmix02 meshmix01

Yup. I was going to print a physical model with a tolerance of 3.34 microns (those measures on the MeshMixer are in millimeters). What could possibly go wrong with expecting that kind of resolution?

I had Shapeways print these in steel; one half with “stainless” finish and the other with “matte bronze” finish. Their process for printing steel involves using printing layers using liquid binder and a fine steel powder, then infusing the combined structure with (presumably liquid) brass. Pretty crazy! They claim an accuracy of ±1% with a layer thickness of 0.1mm.

Here’s what I got back:
IMG_5016
Pretty nice!

It’s no big surprise that they don’t interlock as originally envisioned. For Christmas, I received a very nice micrometer set (thanks to E & Simon!), so I tried measuring my rings. I’m still learning proper micrometer technique, and it’s an interesting challenge to measure complicated shapes.

IMG_5021 IMG_5019

These measurements are farther off than I expected, even after reviewing my initial assumptions and realizing they were unrealistic. I see three possibilities to explain this:
1. My measuring technique still needs refinement.
2. My digital modeling tools are less accurate than I thought.
3. Shapeways is less accurate than they report.

In all likelihood, it’s a combination of the first two (and maybe all three). I strongly suspect I am not measuring the very edge dimension of a flared shape correctly. MoI is not really designed for high-precision engineering models. It’s NURBs based, and I had to convert the model into a polygonal STL file for printing. I did my measurement of the resultant STL file in MeshMixer.

In any case, this may not have produced the exact end results I desired, but it’s been educational. As I learn more, I’ll post more here.


Tue, 2 Dec 2014

Compiling Kannel 1.4.4 under Centos 7.0

— SjG @ 4:28 pm

This took me while to get to work. If you follow these steps in order, it should work nicely.


# yum install mariadb-devel
# yum install libxml2-devel
# yum install bison
# yum install byacc
# cd /usr/local/src
# wget http://kannel.org/download/1.4.4/gateway-1.4.4.tar.gz
# tar xzvf gateway-1.4.4.tar.gz
# cd gateway-1.4.4
# ./configure --prefix=/usr/local/kannel --with-mysql --with-mysql-dir=/usr/include/mysql --disable-wap
# make

There are a few tricks here. First, just having libxml2 installed is not enough. You need the libxml development headers, etc. Should be obvious, but tricked me. Next, if you run ./configure before you have some of the dependencies installed (e.g., Bison), you will have modified source files that will still fail even after you install the dependency. Thus it’s important to install all that stuff before you run ./configure.

This stuff isn’t really that hard, but it can be time consuming to track down why it’s not working.


Sat, 8 Nov 2014

A Maker-ing We Will Go

— SjG @ 6:54 pm

When I was growing up, I was encouraged to make things. Well, rewind a bit. I was known for “putting things to the hammer,” i.e., breaking stuff. Sometimes, this was in pursuit of figuring out how they worked, or changing how they worked. This would frustrate my father, who was and is very good at actually fixing things. To quote Gandalf:

“He that breaks a thing to find out what it is has left the path of wisdom.” — J.R.R. Tolkien

Still, putting things to the hammer can be very educational. I attribute much of my mechanical intuition to having disassembled things and trying (with frequent failures) to put them back together again.

In any case, all this is to say that today I enjoy making things, whether mechanical, electrical, ceramic, or even virtual. I’ve been dabbling in exploring some of the new technologies that are becoming affordable to dabblers1 like me. I’ve gone to “Maker Spaces,” learned about 3D printers and laser cutters and engravers. I’ve become marginally familiar with file formats and techniques, and have played around with building models and uploading them to service bureaus like Shapeways to see how much it would cost to print them.

I’ve been meaning to start actually using some of these technologies, but have had a lot of questions. For example, I’ve designed a few lines of products that I think I could probably sell (nothing spectacular, but things that I think could be interesting). I’ve looked at 3D printing of them, but haven’t actually gotten to it. So when I read about SoCalMakerCon, I thought it’d be worth checking out.

It was definitely educational. I met a lot of friendly makers, and I saw many 3D printers in action, which helped me get a feel for the different approaches. I learned a lot about 3D print materials. The prices are way down from where they had been (there were what appeared to be decent single-spool printers at the $700 price point). Laser cutters and engravers are remain a lot more expensive.

Still, I continue to wonder about the economics of it. Say I were to start creating the tchotchkes I’ve designed, what would be the financial breakdown for 3D printing? I’ll start with ignoring the cost of electricity, design time, and I’ll make the assumption that I could re-purpose one of the old computers I have lying around to be the printing control workstation. I’ll also leaving out the cost of the time to babysit the printer and manage the printing. Print filament is around $30/kg, and I could print maybe 50 items per kilogram (give or take a factor of two). If I could sell them online at $25 per through a site like Etsy, I’d be seeing maybe $23 per unit with the expenses2, minus packaging and shipping. So to pay off a $1500 printer, I’d need to move 65 units. Ambitious? I don’t really have any idea. I don’t know how well something made in plastic will sell, and I’m new to the world of marketing crafts on Etsy.

Maybe the right business model is to print out a plastic prototype, and have the items themselves manufactured in China. That’d be a whole new can of worms that I know nothing about. But it would mean I could have the items in metal, or ceramic, or cast in resin. It would almost certainly be a much bigger leap — there would be up-front manufacturing costs, and because it’s not “create on demand,” I’d have to invest in an inventory.

Anyway, all interesting thoughts. I’m not sure any of it will go anywhere. But I will continue to be interested, and see what I can learn. If I jump in, there’ll be a new category added to this site, and I’ll post things in process, lessons learned, and more.

1 In the old days, we didn’t have fancy labels like “Makers” or DIY-ers. People just did made stuff. They were hobbyists. Those of us who didn’t have one particular focus were dabblers and dilettantes.
2 Sites like Etsy charge a listing fee of $0.2 and a 3.5% fee on sale. That’s pretty good!


Sat, 25 Oct 2014

Simple Budgeting Spreadsheet

— SjG @ 7:21 pm

Sometimes, simple is best.

Here’s a simple Open Office spreadsheet to help visualize what your “Daily Nut” is when it comes to expenses and income. It makes it easy to visualize how much that daily coffee and doughnut cost you over the course of a year, or shows you how much more discretionary spending you can engage in before causing yourself serious trouble. Then again, if you have discretionary spending money, I’d advise putting half into savings or investments, and giving the other half to charity. But that’s just me.

ScreenShot

Get the spreadsheet over on GitHub:
https://github.com/libelle/the-daily-nut


Wed, 17 Sep 2014

PHP 5.5, PHPUnit/Selenium, Yii, and Mac Ports on Mavericks.

— SjG @ 4:07 pm

There is a special place in hell where every programming project creates its own package manager and you have to use it if you want to use the project. Oh, wait. That’s not a special place in hell. That’s here. Crap.

Some days, I shouldn’t bother getting out of bed. On those days, I have that weird broken cognition that I call “user brain” — I don’t read error messages, I don’t stop to think, and instead of looking at problems and trying to solve them, I randomly bounce around and break things.

So I had User Brain. I was setting up a new name-based SSL virtual host in my development environment, and dropped a line from the configuration. Then I didn’t read the Apache error message carefully, and foolishly thought “Oh, I must need to update my certificate trust chain.” This resulted in my updating my environment via mac ports — and when it asked me if I wanted to migrate from php5 to php5.4, I said OK.

When I finished that process, my development environment was completely b0rken, and I hadn’t solved the original problem. Fast forward an hour of questionable language, and I had a new strategy. Install PHP 5.5!

There are several guides out there on how to make all this stuff work, but they didn’t really work for me. What did, was the following. First, I logged in as root. If I’m going to make stupid mistakes, it’s best to do it with unlimited power. Anything else is unsporting.

# port uninstall --follow-dependents php54

That got rid of all the PHP 5.4 stuff left over from my previous debacle. So now it’s time to install PHP 5.5, and the various modules I need:

# port selfupdate
# port upgrade outdated
# port install php55 php55-gd php55-mbstring php55-iconv php55-curl php55-zip php55-soap php55-pcntl php55-xmlrpc php55-openssl php55-sockets php55-imagick php55-mcrypt php55-solr php55-mysql
# port select --set php php55
# port install php55-apache2handler
# cd /opt/local/apache2/modules
# /opt/local/apache2/bin/apxs -a -e -n php5 mod_php55.so

That’s all pretty straightforward. But my httpd.conf had a few stray lines in it that needed cleaning up. I had to replace LoadModule php5_module modules/mod_php54.so
with
LoadModule php5_module modules/mod_php55.so
and change
Include conf/extra/mod_php54.conf

to

Include conf/extra/mod_php55.conf

Now I could start up Apache and see what kinds of errors I had.

# /opt/local/apache2/bin/apachectl restart

Well, this is where I finally found and fixed the dropped line that got me started on this whole sordid adventure. I also discovered I didn’t have a good php.ini file, so I copied the distribution one and customized it.

# cp /opt/local/etc/php55/php.ini-development /opt/local/etc/php55/php.ini
# vi !$
# /opt/local/apache2/bin/apachectl restart

Now my dev sites were back up, but I couldn’t run tests. The way that phpunit is structured has changed since the days when it was a Pear package. It now uses a phar package and composer. Now, at some point, I’ll restructure my Yii projects the New Right Way and have a phpunit distribution per project, but I need to get back productive, so I set it up globally for the time being.

# cd /opt/local/bin
# curl -sS https://getcomposer.org/installer | php
# mv composer.phar composer
# wget https://phar.phpunit.de/phpunit.phar
# chmod +x phpunit.phar
# mv phpunit.phar phpunit
# composer global require 'phpunit/phpunit-selenium=*'
# composer global require 'phpunit/phpunit-story=*'
# composer global require 'phpunit/dbunit=*'
# composer global require 'phpunit/php-invoker=*'

This is where I discovered the php.ini had set the default include path to a not-quite-right location. I ended up changing

include_path=".:/opt/local/lib/php5/lib/php"

to
include_path=".:/opt/local/lib/php"

and then once again restarted the environment.
# /opt/local/apache2/bin/apachectl restart

Now there were only two things wrong. The current project is based on Yii 1.1.x, and it still tries to include individual PHPUnit files.

Based on numerous forum posts and false starts, I edited framework/test/CtestCase.php, and changed those “requires” up top to:

if (!method_exists('PHPUnit_Runner_Version', 'id') ||
version_compare(PHPUnit_Runner_Version::id(), '4', '< =') ) { require_once('PHPUnit/Runner/Version.php'); require_once('PHPUnit/Autoload.php'); }

PHPUnit unit tests now run, as do Selenium tests, but they do throw an ugly warning on test failures to tell me:

Warning: include(): Failed opening 'PHPUnit_Extensions_Story_TestCase.php' for inclusion (include_path='.:/Users/samuelg/project/X/Y/protected/commands:/Users/samuelg/project/X/Y/protected/behaviors:/Users/samuelg/project/X/Y/protected/components:/Users/samuelg/project/X/Y/protected/nuclear_secrets:/Users/samuelg/project/X/Y/protected/models:/opt/local/lib/php') in /Users/samuelg/project/X/Y/framework/YiiBase.php on line 418

Nor does it give me line numbers of failures in Selenium tests if I enable screenshots. It’s also seemingly taking screen shots of the wrong pages of the site when there’s an error. I don’t yet have a solution to any of these problems.

Lastly, PHP 5.5 is more sensitive about some things than I expected. First, I had to migrate some crappy developer support code from using direct mysql commands (e.g., mysql_connect, mysql_query, etc.) as they’re deprecated. I now use PDO, and that’s all fine.

But beware PHP being stupid about what’s a variable and what’s a reference. In PHP 5.5 strict mode, it whimpers about things like

$foo = end(my_func());

even if my_func() returns an array. Now, in a sane language, I’d be able to do stuff like that, because hey! an array’s an array, even if it’s being returned by a function! I mean, not to devolve into pointless discussion of language implementations and flaws, but flaming owls of imminent death, is PHP a mess!

Anyway, this post is a mostly cleaned-up version of my little adventure. If it spares anyone else some of the same pain, it will be worth while.

No, the project doesn’t really have a nuclear secrets directory. I just felt stupid nerfing the project name in the first place.