Skip to content

Instantly share code, notes, and snippets.

@mayoff
mayoff / makeAnimatedGif.m
Created February 16, 2013 23:00
Example of creating an animated GIF on iOS, with no 3rd-party code required. This should also be easy to port to OS X.
#import <UIKit/UIKit.h>
#import <ImageIO/ImageIO.h>
#import <MobileCoreServices/MobileCoreServices.h>
static UIImage *frameImage(CGSize size, CGFloat radians) {
UIGraphicsBeginImageContextWithOptions(size, YES, 1); {
[[UIColor whiteColor] setFill];
UIRectFill(CGRectInfinite);
CGContextRef gc = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(gc, size.width / 2, size.height / 2);
@joeytwiddle
joeytwiddle / gist:6129676
Last active December 20, 2022 15:25
Deep population helper for mongoose
// Example usage:
// deepPopulate(blogPost, "comments comments._creator comments._creator.blogposts", {sort:{title:-1}}, callback);
// Note that the options get passed at *every* level!
// Also note that you must populate the shallower documents before the deeper ones.
function deepPopulate(doc, pathListString, options, callback) {
var listOfPathsToPopulate = pathListString.split(" ");
function doNext() {
if (listOfPathsToPopulate.length == 0) {
// Now all the things underneath the original doc should be populated. Thanks mongoose!
callback(null,doc);
@levity
levity / mosql.rake
Created March 25, 2014 22:55
Rake task for MoSQL on Heroku
# This is a simplified version of what we're using in production for drinksoma.com
namespace :mosql do
task :run => :environment do
conf_path = Rails.root.join('config', 'collections.yml')
cmd = "mosql -c #{conf_path} --sql #{ENV['MOSQL_POSTGRES_URI']} --mongo #{ENV['MOSQL_MONGO_URI']}"
IO.popen(cmd) do |child|
trap('TERM') { Process.kill 'INT', child.pid }
$stdout.sync = true
@jadaradix
jadaradix / iMessage-sql.sh
Last active June 20, 2017 21:29
Create an SQL file (dump) of OS X iMessage messages.
echo ".dump" | sqlite3 ~/Library/Messages/chat.db > $(date +"%y-%m-%d").sql