metapundit.net is my personal ramblings on technology, programming,
art, theology and whatever else strikes my fancy...
Even if I don't know what character that "e with dots over it" character is supposed to be.
I'm talking of course about Raphael JS - a Javascript library for drawing svg based vector graphics in the browser. I'd seen Raphael a bit ago and was thinking about it for some charting I had to do for a client's web app. Raphael wasn't exactly the right fit but I've been meaning to learn it forever so I added it to a little side project.
learnchordmelody.com is a site I made to keep track of resources I find online about Chord Melody/Jazz Guitar playing and theory. I partly made it to clear out my bookmarks folder and partly because I wanted to make a clean slate site - It's html5 (I LOVE doctype html - finally a doctype I can remember) with some CSS3 features like rounded borders, drop shadows, multi-column layout, and embedded fonts. I used a handrolled microframework in PHP that makes it easy to update. I don't really have design chops but I sketched an outline of a Jazz guitar for the header, picked a handwritten font from Google's Font API and I think it looks decent.
I added the touch of Raphael to replace the sort of thing people use Flash for - a bit of animation. If you visit the site and mouse over the menu items using a decent browser the little treble clef morphs into an eighth note. (This works in tested IE7, Chrome, and Firefox 3 - your results may vary). The animation even worked in IE6 (Raphael uses VML in IE) but it created a layout bug I'm too lazy to fix so I disabled it for IE6. This wasn't rocket science but it's kind of cute (really Mom, check it out!)
Working with Raphael was fairly easy - I got copyright free svg drawings from WikiMedia Commons, scaled them and copied and pasted the svg path information from Inkscape into a javascript file. I then drew a little canvas in each menu item and started the animation on mouseover. I wanted to animate back to the treble clef on mouseout but Raphael doesn't have an animation queue built in and the quick solution I hacked together looked too abrupt. Besides - I wanted to keep this short and (excluding the svg path info) I've only got 14 lines of JS.
The only other issue I ran into was getting the canvas objects (Raphael calls them "Paper" as it isn't an html5 canvas) from the mouseover event on another DOM object. Using Jquery I would typically select a DOM object and manipulate it. I could select the dom node representing the svg object but I couldn't figure out how to get back to the Paper (Raphael object with animation methods) from the DOM node. I ended up making a javascript list of Paper objects and matching the menu item that had the event to the ith item in the Javascript list - there might be a better way of doing this...
Anyways - take a look - If I can come up with a better use case than animated icons I'll definitely revisit Raphael.
Date Posted: Aug 16th 2010, 11:47 PM
Comments
So I got a Dell Zino to serve as my Windows testing box/second computer. It came with Windows 7 Home Premium 64. Which would not allow me to map a network drive to my DNS-323 network storage device - it wouldn't authenticate.
After much searching I discover that you need to adjust your security policies to allow a particular version of NTLM but Windows 7 Home doesn't include the securities policy editor. Pro only, that. Fortunately you can edit a registry key:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"lmcompatibilitylevel"=dword:00000002
to get what you needed. Thanks hardwarecentral.com! And uh - I guess Microsoft considers network storage to be a Pro only feature. Or maybe they think Home users should be wielding regedit... Whatever.
Date Posted: Mar 17th 2010, 01:02 AM
Comments
Actually I've had a couple of hiccups in my previously datailed server migration. Well - check that - this my second server migration; don't ask about the first one!
Anyways, I need PIL and Pycrypto for my Django/Satchmo sites. Using easy_install to setup Pycrypto didn't work; the compilation bailed with the error message "ld: cannot find -lpython". I'm somewhat familiar with this problem - you get this when the linking portion of compilation can't find a needed .so library. Most linux systems maintain a system to configure search paths and build a cache of dynamically linkable libraries. The walkthrough I'd followed had me add a file with the path of the python 2.6 .so in /etc/ld.so.conf and rebuild the linker cache with ldconfig. I verified (ldconfig -p | grep python) that the linker cache was aware of libpython.2.6.so. I tried fiddling with some environmental variables that allegedly set the LD search path; but testing via "ld -lpython2.6" still produced the error message, while manually setting the LD path (ld -lpython2.6 -L /opt/python2.6/lib) worked. Yes I looked at the privileges on the .so file and containing directory without finding a problem. Eventually I copied the .so file to a known location with
cp /opt/python2.6/lib/libpython2.6.so /usr/lib
and was able to sucessfully build Pycrypto. The next piece I needed was the Python Imaging Library and it had seemed to easy_install without incident. When I started a Django site, however, it stopped running with a cryptic error message: "AccessInit: hash collision". Googling yielded nothing except the C source code for the PIL module. I have no idea what provoked the crash and running a couple of scripts I had that used PIL to resize images didn't generate the exit either. Downloading the latest version and running the setup.py file generated a working install...
There's a reason I'm not a sysadmin. Solving problems with code makes me happy - and hard problems just make me think harder. I want to understand the problem and come up with a good solution! Sysadmin problems (broken environments) just make me swear frenziedly and I don't care so much about the solution, I just want stuff to work so I can get on with my job. I wasted several hours between PIL and Pycrpto and I still don't know why ld couldn't find my libraries or even what the AccessInit error mesage from PIL meant (besides the fact that two different things hashed to the same value that apparently shouldn't). Hopefully posting my travails helps somebody else who bumps into the same problem...
Update: I should clarify one thing - I said above that "I wasted several hours between PIL and PyCrypto". I meant that merely as a description of the problems I was working on - both of those packages are solid pieces of code with a wide user base. Obviously the problems I'm encountering are because I'm building a non-standard environment. Anyways - I'm not capping on any particular piece of software here... Just complaining about my skills and inclinations that make sysadmin stuff possible for me but not particularly enjoyable.
Date Posted: Jan 28th 2010, 04:40 PM
Comments
I recently completed a migration for a customer from a VPS with CentOS 4 and whm/cpanel to a new dedicated server with CentOS 5. The box had a variety of websites in PHP and Python/Django so I took the opportunity to switch from Apache proxied to Lighttpd for the Django sites to mod_wsgi. I can't guarantee that this is the best way to set things up - but it works for me.
Following are some of the steps necessary to complete the move:
First I compiled and installed a newer version of Python (CentOS 5
comes with Python 2.4) and compiled and installed mod_wsgi using this
helpful guide - although I went for Python 2.6 and mod_wsgi
3.1. This also got MySQLdb and setuptools compiled and installed for
my new python 2.6. No particular surprises here.
I'm reusing the Python environment customization I used on the last
server - adding a simple sitecustomize.py file to the site-packages
directory. See the site module
docs for details. My sitecustomize.py:
import os, site
site.addsitedir(os.path.expanduser("~/.python"))
Next up is hooking my django site into mod_wsgi. Cpanel has a
heavily customized Apache setup - you can't directly edit the
httpd.conf nor does it simply include vhost.conf files - instead it
has a baroque system of include files. I added include files that get
added to the bottom of the vhost section as documented at the cpanel
website. So for "domain.com" and user "test" I added a .conf file at
/usr/local/apache/conf/userdata/std/2/test/domain.com/. My django.conf file looks like:
WSGIDaemonProcess test user=test display-name=%
WSGIProcessGroup test
WSGIApplicationGroup %
If my site had an ssl cert CPanel had a separate VirtualHost
section for port 443 so I needed an additional config file at
/usr/local/apache/conf/userdata/ssl/2/test/domain.com/. I couldn't
just duplicate the django.conf used for port 80 - this would try to
create a duplicate wsgi process group and fail. Thanks to Graham
Dumpleton's blog I realised I only need to duplicate the
WSGIProcessGroup declaration to hook into the existing wsgi process
group and have the same Django instance serve both virtualhost
declarations. Unfortunately the cpanel command I was running to
collect the include files (/scripts/ensure_vhost_includes
--user=username as per Cpanel's
documentation) now complained about duplicate
declarations. Running /usr/local/cpanel/bin/build_apache_conf instead
sucessfully rebuilt the httpd.conf file - I have no idea why. I really
don't like the non-standard Apache config system...
Now I need to hook up my wsgi application. In my ~public_html
directories I add a django.wsgi file that looks like this:
#!/usr/bin/python
import os, sys, site, pwd
user = pwd.getpwuid(os.getuid())[0]
sys.stdout = sys.stderr
site.addsitedir(os.path.expanduser("~%s/.python" % user))
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
#def application(environ, start_response):
# start_response('200 OK', [('content-type', 'text/plain')])
# return (user,)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
A few details about the code - I seemed to get hit by a bug
(Apache? wsgi? python?) where python thought I was user nobody even
though I have mod_wsgi configured to run each wsgi processgroup as the
appropriate user. The os.getuid stuff is to sniff what my username
actually is - os.path.expanduser("~") was yielding "/home/nobody" for
whatever reason. I've also got sys.stdout set to stderr since for wsgi
applications print to stdout causes an exception... And yeah - I've
got a print statement or two buried in some code somewhere. I've also
got a commented-out "world's simplest possible wsgi app" thanks to Eric
Florenzano. Very useful for debugging (It's how I figured out the
expanduser problem, for example). When I've got things figured out I comment it out and use the standard Django wsgi handler.
I then use mod_rewrite to hook up to my django.wsgi like so:
RewriteRule ^static/(.*)$ - [L]
RewriteRule ^admin_media/(.*)$ - [L]
RewriteCond % !-f
RewriteCond % !(django.wsgi)
RewriteRule ^(.*)$ /django.wsgi/$1 [QSA,PT,L]
And that's pretty much it...
Date Posted: Jan 25th 2010, 12:03 AM
Comments
Ok - this is a great little bookmarklet. Installing it allows you to reformat pages with lengthy articles into restful, uncluttered, spacious reading experience with a single click. It's earned a spot on my toolbar next to the Design bookmarklet I use all the time...
Date Posted: Jan 1st 2010, 10:48 PM
Comments
Archive: 1 | 2 | 3 » [16]