Data URI manipulation made easy.
This isn't very robust, and will reject a number of valid data URIs. However, it meets the most useful case: a mimetype, a charset, and the base64 flag.
| #!/usr/bin/env ruby -w | |
| # brew-services(1) - Easily start and stop formulas via launchctl | |
| # =============================================================== | |
| # | |
| # ## SYNOPSIS | |
| # | |
| # [<sudo>] `brew services` `list`<br> | |
| # [<sudo>] `brew services` `restart` <formula><br> | |
| # [<sudo>] `brew services` `start` <formula> [<plist>]<br> | 
| /** | |
| * UTILS module - contains a number of general methods. | |
| * Inspired by http://javascript.crockford.com/remedial.html | |
| * */ | |
| var UTILS = (function (utils, $) { | |
| "use strict"; | |
| /** | |
| * Improved typeof method, distinguishes <array> and <null> from object | |
| */ | 
| // Intercepting HTTP calls with AngularJS. | |
| angular.module('MyApp', []) | |
| .config(function ($provide, $httpProvider) { | |
| // Intercept http calls. | |
| $provide.factory('MyHttpInterceptor', function ($q) { | |
| return { | |
| // On request success | |
| request: function (config) { | |
| // console.log(config); // Contains the data about the request before it is sent. | 
| # A class-based template for jQuery plugins in Coffeescript | |
| # | |
| # $('.target').myPlugin({ paramA: 'not-foo' }); | |
| # $('.target').myPlugin('myMethod', 'Hello, world'); | |
| # | |
| # Check out Alan Hogan's original jQuery plugin template: | |
| # https://github.com/alanhogan/Coffeescript-jQuery-Plugin-Template | |
| # | |
| (($, window) -> | 
| @zed = @zed ? {} | |
| @zed.info = do -> | |
| #private | |
| name = "" | |
| getName = -> name | |
| setName = (value) -> name = value | |
| age = 0 | |
| getAge = -> age | 
| web: run-program gunicorn arena.wsgi | |
| celery_beat: run-program celery -A arena beat -l info | |
| celery1: run-program celery -A arena worker -Q default -l info --purge -n default_worker | |
| celery2: run-program celery -A arena worker -Q feeds -l info --purge -n feeds_worker | 
| -- http://stackoverflow.com/questions/1124603/grouped-limit-in-postgresql-show-the-first-n-rows-for-each-group | |
| -- http://www.postgresql.jp/document/9.2/html/tutorial-window.html | |
| CREATE TABLE empsalary ( | |
| depname varchar(10) not null | |
| , empno integer not null | |
| , salary integer not null | |
| ); | |
| INSERT INTO empsalary (depname, empno, salary) VALUES ('develop', 11, 5200); | 
| import base64 | |
| import cStringIO | |
| from django.core.files.uploadedfile import InMemoryUploadedFile | |
| # ... | |
| if request.POST.get('file') and request.POST.get('name'): | |
| file = cStringIO.StringIO(base64.b64decode(request.POST['file'])) | |
| image = InMemoryUploadedFile(file, | |
| field_name='file', |