Skip to content

Instantly share code, notes, and snippets.

@bohde
bohde / tags.py
Created January 30, 2012 03:25
Using django-taggit with django-tastypie
from tastypie.fields import ListField
class TaggedResource(ModelResource):
tags = ListField()
class Meta:
queryset = Model.objects.all()
def build_filters(self, filters=None):
if filters is None:
@chetan
chetan / yardoc_cheatsheet.md
Last active May 10, 2024 02:53
YARD cheatsheet
@snikch
snikch / gist:3661188
Created September 6, 2012 23:16
Find the current top view controller for your iOS application
- (UIViewController *)topViewController{
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController];
}
- (UIViewController *)topViewController:(UIViewController *)rootViewController
{
if (rootViewController.presentedViewController == nil) {
return rootViewController;
}
@dhendo
dhendo / gist:4277592
Created December 13, 2012 16:21
Mongo Model Serializer for django-rest-framework
import mongoengine
class MongoModelSerializer(serializers.ModelSerializer):
def get_default_fields(self):
cls = self.opts.model
opts = get_concrete_model(cls)
#pk_field = opts.pk
fields = []
fields += [getattr(opts, field) for field in opts._fields]
#fields += [field for field in opts.many_to_many if field.serialize]
@toolmantim
toolmantim / Opsworks Overview.markdown
Last active August 2, 2017 12:35
After messing with OpsWorks for a few days I thought I'd document my own introduction to it's most important bits.

OpsWorks

AWS OpsWorks, formerly Scalarium, is a chef-based system that deeply integrates with EC2 (security policies, key pairs, etc). OpsWorks acts as web console to configure your entire system, and as a command hub for running chef-solo on all the instances.

Stacks

A stack represents a collection of inter-connected and inter-configured services.

A stack has lifecycle events which are triggered by any change to the stack configuration (such as, adding a new instance to a layer, or changing the hosts of an application). In this way, the stack acts as an event hub, notifying every instance of any changes.

@DanKnox
DanKnox / websocket-rails_message_format.js
Last active February 10, 2016 14:00
Format of WebsocketRails Messages
/****** Current Format ******/
// Basic Message
metadata = {
id: 1234234234, // Randomly generated by the client. Used for receiving success/fail callbacks
client_id: 123456 // Sent from the server with the `websocket_rails.client_connected` event which is sent after the connection is opened. Store this and send it with each message.
data: {name: 'shoes'} // Arbitrary data. Can be Object or String. This is available through #message or #data in the controller.
}
event = ["products.new", metadata]
@akdetrick
akdetrick / rvm-to-rbenv.md
Last active June 12, 2024 03:19
Guide to switching to rbenv bliss from RVM hell

RVM to rbenv

Why? @sstephenson explains it best here.


1) remove RVM from your system

This should get rid of the rvm dir and any installed rubies:

$ rvm implode
@lmmendes
lmmendes / fake_email_validator.rb
Created May 13, 2014 14:58
Fake / Temp e-mail validator
# encoding: utf-8
# Validates that the specified attributes are fake e-mail from temp domains
#
# class Person < ActiveRecord::Base
# validates :email, :fake_email => true
# end
#
# class Person < ActiveRecord::Base
# validates :email, :fake_email => { :exclude => ['bobmail.info'] }
@miguelcma
miguelcma / ios_is_debug.m
Last active August 29, 2015 14:13
iOS is_debug?
+ (BOOL)isDebugMode
{
if ([HKDevice isSimulator]) return YES;
static BOOL isDebugMode = NO;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// There is no provisioning profile in AppStore Apps.
NSData *data = [NSData dataWithContentsOfFile:[NSBundle.mainBundle pathForResource:@"embedded" ofType:@"mobileprovision"]];
if (data) {
@jasoares
jasoares / mongod0.conf
Last active February 24, 2022 21:54
MongoDB config file template
systemLog:
destination: file
path: '/usr/local/var/log/mongodb/mongod0.log'
logAppend: true
storage:
dbPath: '/usr/local/var/mongodb0'
directoryPerDB: true
journal:
enabled: true
engine: wiredTiger