- Python Comprehensions
- 19.6.2009
I haven't posted in a whilte, so here's a fun fact for the day: Although they probably aren't the best way to do most problems, they sure are cool - Python Comprehensions. When you combine a list comprehension with the reduce() function, the one-liner possibilities are endless. For example, if you need a quick and dirty way to calculate the XOR checksum of something (eg. NMEA 0183 GPS output), create a function such as:
import operator def checksum(s): return reduce(operator.xor, [ord(c) for c in s])It may not be as universally accepted as unrolling ...
- no comments
- Django HTML Admin Widget
- 3.5.2009
I was a bit annoyed at the lack of WYSIWYG fields for Django's admin interface. I was originally planning to use FCKEditor but couldn't find a polished Django implementation (although I'm sure there is one out there). Instead I opted to use TinyMCE due to this nice Django widget implementation. After running setup.py, installation is a cinch - I just added
from tinymce import models as tinymce_models, and replaced instances ofmodels.TextField()withtinymce_models.HTMLField(). To customize the options available to TinyMCE, I was able to add this to my settings.py:TINYMCE_DEFAULT_CONFIG = { 'theme': "advanced", 'theme_advanced_toolbar_location ...- 1 comments
- Django Caching
- 29.4.2009
The site just got mildly reddited, so I've decided to implement some caching in order to deal with possibly higher loads in the future (when I unveil a large-scale autonomous project that I've been working on). On my ongoing quest of Django awesomness, I have recently stumbled upon generic views, which somewhat clouded the idea of caching.
First, the Django docs provide an example that lists something like(r'^foo/(\d{1,2})/$', cache_page(my_view, 60 * 15)),to be put in urls.py in order to cache a view. However, this is quite contradictory to their other references ...- no comments
- Simple Python ctypes Example
- 25.4.2009
I have been working with the massive data tables generated by my balloon flight and have run into a bit of trouble with Python. Everyone knows that Python isn't the fastest kid on the block. However, there are several ways you can speed it up. First off, Python 2.6 and 3.0 provide a new multiprocessing library that makes it much easier to divide a problem amongst concurrent workers. However, this is still not ideal for high throughput data requirements. I have previously worked with Python's C API, but found it's syntax quite undesirable. This new ...
- 9 comments
- SVGs, Microcontrollers, and Xbees
- 16.4.2009
I brought back and old project this afternoon. I had previously constructed a temperature regulated refrigerator using an Arduino and 5A Omron SSR to toggle the compressor, but had no good way of plotting the results to make sure my refrigeration algorithms were working correctly. The refrigerator was not near a PC, so uploading the live results to a database was out of the question.
However, I recently purchased some XBee modules to play with wireless serial communication, and decided to give them a try with a datalogging application. I picked up an XBee shield for the Arduino and a ...- 2 comments
- Twitter Mailing Functionality
- 8.4.2009
I had to jump on the Twitter bandwagon to enter a contest and must admit - I'm quite frustrated with the features that are present. Twitter seems to be mostly SMS driven in a world of emerging (and free!... with data plan) PUSH email. Therefore, since I refuse to pay extra for SMS, I must log in to check for @reply's to my tweets. Also, I can't just send a quick email update to Twitter on my mobile device, but rather have to log into their web interface on my painfully slow mobile device.
Anyway - I have started ...- 2 comments
- Stylesheets
- 31.3.2009
Ok, I get it. The site needs more color. I had a decent older design, but I decided it was time for some housekeeping during the server move. Thankfully, the guys at merge may have motivated me. I feel like I have dedicated enough time to learning the nuances of django, and now it's time to work on the fsckd UI a bit more.
Anyway, I spent some time in a photo shoot tonight trying to with merge's give a shirt contest, and thought I would share the results.- 3 comments
- High Altitude Weather Ballooning
- 31.3.2009
I just finished up a weather balloon project over the weekend. Here are some pictures of the launch and subsequent recovery.
The goal was to measure atmospheric gravity waves by using direction tubes and thermistors to detect pressure differences between the two openings of the tube. Our apparatus measures the associated temperature fluctuation, and logs ADC readings to a CF card every half second. In order to compensate for balloon rotation, we stuck a HMC6352 digital compass in the payload as well.
Our data logging system was composed centered around a TS-7200 from Technologic Systems. We opted for the add-on ...- no comments
- Captcha
- 29.3.2009
Bots started posting spam here this morning, so I implemented my own captcha based on FIGlet. I may eventually switch to reCAPTCHA, but it didn't work to my liking last time I implemented it.
FIGlet offers several benefits over traditional captchas at this time. First, FIGlet doesn't have to do any CPU intensive image generation. FIGlet is also a much simpler program in general, which makes it more malleable to the developer as compared to something such as PIL. And most important (at least for now), every capcha bot that I have seen is based on OCR. Because ...- 5 comments
- <3 Django
- 27.3.2009
Let me save you lots of trouble, and start by saying that Django is the perfect MVC framework. Ok, maybe not perfect, but compared to others it certainly looks that way. The community and documentation alone are enough reason to switch your existing projects - not to mention the built-in admin interface and endless time-saving features. Each week I learn about some new that could have saved hours of coding.
Moreover, Python's functional programming attitude combined with the Django furthering the concepts of DRY for the web create a rapid development and high performance environment that blows PHP out of ...- 5 comments
