Here’s a GUID generator that delivers them in a configurable alphabet instead of the more familiar format e.g.
3F2504E0-4F89-41D3-9A0C-0305E82C3301. Basically a port of shortuuid in python by Stochastic Technologies.
It is possible to have too much fun generating GUIDs for your next project… Just make sure your custom alphabet has unique characters and no one will get hurt.
Continue reading Vanity GUIDs for Fun Maybe Profit
Here’s a technique I used for adding overlay icons to represent various states of a base view model. Typically, you’ll have a
DataTemplate for your primary view model. If the model can be in various states, however, it becomes annoying to manage the data triggers to change the look of the icon, e.g. using adorners.
Continue reading Using the State Pattern for Adorning in XAML
I’ve got a project developing an API in C# and my development machine is Linux. This is how I integrated building the API Blueprint documentation with the Monodevelop IDE and served it using Nancy self-hosting.
Continue reading Building API Documentation with Nancy and Monodevelop
Recently, I’ve had the pleasure of accumulating over 1 million thumbnail and preview images on my drive. I like having as many files on my disk as the next guy, but I thought since I’m using MongoDB anyway, why not use GridFS to store the images!
The trick was to fetch an image at a URL, save it into GridFS, then be able to serve it back out – all without temp files or creating individual files for every image. Here’s a recipe that does it all!
Continue reading Serving Images with MongoDB, GridFS and Flask
Here’s a gist combining Backbone.js views and routes with API-driven tables from datatables.net. HTML not included, but it should be fairly obvious what’s going on here… a simple app for browsing auction listings.
Continue reading Backbone.js Template: API-Driven Data Tables
Whoever said scraping web pages can’t be fun never tried it using Python decorators and generators! We’ll use this mini-framework to fetch all the upcoming comic book releases from one of my favorite online comic book stores.
A couple of interesting things going on here programmatically: 1) using decorators that are static methods of a class that maintains some state for the decorated operations and 2) decorating class methods that are generators – the typical decorator can’t handle a yielded result…
Continue reading Decorators, Scrapers and Generators
These were my results searching for a default avatar for a Tumblr blog. Clearly ‘metadata’ isn’t being used here, just low-level image features… Vermont, OK. But, Minnesota? Come on!
It’s even more apparent that NO ‘metadata’ is being used when Google Maps map tiles make it in the results…
It’s REALLY hard to deliver relevant images similarity results without any context…
In this Backbone.js recipe, we’re going to allow updating a view via events triggered from any sub-view. The view won’t need a refresh(), because it will be bound to model change events using Rivets.
tl;dr; live demo and gist
Continue reading Updating Views with Events, Models and Rivets
Here’s a quick fiddle that shows how to route a command between sub-views no matter how they’re nested in the DOM. Basically, when a sub-view is rendered it triggers a subscribe event that’s captured by the application view which then sets a delegate on another sub-view. This other sub-view is the source of the events, e.g. a menu bar.
When the event source sub-view triggers events (e.g. clicking a link), it does so on the delegate. Event names are specified in the HTML using a
data-event attribute on the link. Enjoy!
Continue reading Routed Commands for Backbone.js
Here’s some handy code for generating combinations of strings in Python. Provide a string with substitution variables and a list of iterables, and poof!
Continue reading Simple String Generator in Python