Skip to content

Instantly share code, notes, and snippets.


Nick Merrill nick-merrill

  • Wayfair
  • Boston, MA
View GitHub Profile
nick-merrill /
Last active Aug 29, 2015
Highly useful notification script
alias big="toilet -f bigmono12 -F gay"
color_screen () {
# Expects code like 1;30;42m
cols=$(tput cols)
lines=$(tput lines)
nick-merrill /
Created Dec 5, 2014
A variation on a snippet that handles one-to-one relationships by recursively migrating those relationships' field data to the `primary_object`'s related object.
# Based on
from django.db import transaction
from django.db.models import get_models, Model
from django.contrib.contenttypes.generic import GenericForeignKey
def merge_model_objects(primary_object, alias_objects=None, keep_old=False):
Use this function to merge model objects (i.e. Users, Organizations, Polls,
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "">
<plist version="1.0">
<string>Nick Merrill</string>
<string>App Demo Disc</string>
nick-merrill /
Created Jul 3, 2014
Django: Adds user information to the request's META dictionary, which helps when processing logs via mail_admins.
class ExceptionUserInfoMiddleware(object):
def process_exception(self, request, exception):
user = request.user
if user.is_authenticated():
request.META['USER_ID'] = str(
request.META['USER_NAME'] = str("%s %s" % (user.first_name, user.last_name))
request.META['USER_EMAIL'] = str(
View aliases
# Usage:
# download-site
alias download-site="wget --recursive --page-requisites --html-extension --convert-links --no-parent"
nick-merrill / SelectiveSubviews.m
Last active Aug 29, 2015
This is a convenience function to recursively run code on subviews of specified class types. It's untested, so please just use as a basis for something likely better, perhaps that includes IndexPath counting, etc.
View SelectiveSubviews.m
Example use:
// Return all labels of the cell
NSMutableArray *labels = [Utility ApplyToSubviews:cell limitedToClass:[UILabel class] usingBlock:^(id obj) {
UILabel *label = (UILabel *)obj;
label.text = @"Changed text";
} recursively:YES];