Skip to content

Instantly share code, notes, and snippets.

View nick-merrill's full-sized avatar

Nick Merrill nick-merrill

  • Cobalt AI
  • Boston, MA
View GitHub Profile
@nick-merrill
nick-merrill / xbar_github_prs.py
Last active June 5, 2023 13:07
Load your github PRs along with certain labels that you may care about
#!/Users/nickm/.pyenv/versions/3.9.11/bin/python
import requests
# GitHub username and access token
username = ... # TODO: Fill this in
access_token = ... # TODO: Fill this in
headers = {
"Authorization": f"Bearer {access_token}",
@nick-merrill
nick-merrill / 001-gmail-checker.1m.py
Last active October 24, 2022 22:52
Gmail Checker for xbar
#!/usr/bin/python3
# <xbar.title>Gmail Checker</xbar.title>
# <xbar.version>v0.0.1</xbar.version>
# <xbar.author>Nick Merrill</xbar.author>
# <xbar.author.github>nick.merrill</xbar.author.github>
# <xbar.desc>Checks gmail and displays inbox count</xbar.desc>
import xml.etree.ElementTree as ET
from dataclasses import dataclass
@nick-merrill
nick-merrill / listo_pollo.sh
Last active August 29, 2015 14:20
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)
str="\033[$1"
i=0
@nick-merrill
nick-merrill / merge_model_objects.py
Created December 5, 2014 01:07
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 https://djangosnippets.org/snippets/2283/
from django.db import transaction
from django.db.models import get_models, Model
from django.contrib.contenttypes.generic import GenericForeignKey
@transaction.atomic
def merge_model_objects(primary_object, alias_objects=None, keep_old=False):
"""
Use this function to merge model objects (i.e. Users, Organizations, Polls,
@nick-merrill
nick-merrill / co.nickmerrill.cursors.app-demo-disc.cape
Created September 4, 2014 21:56
Mousecape cursor for demoing apps
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Author</key>
<string>Nick Merrill</string>
<key>CapeName</key>
<string>App Demo Disc</string>
<key>CapeVersion</key>
<real>1</real>
@nick-merrill
nick-merrill / ExceptionUserInfoMiddleware.py
Created July 3, 2014 18:22
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):
try:
user = request.user
if user.is_authenticated():
request.META['USER_ID'] = str(user.id)
request.META['USER_NAME'] = str("%s %s" % (user.first_name, user.last_name))
request.META['USER_EMAIL'] = str(user.email)
except:
pass
# Usage:
# download-site https://django-tastypie.readthedocs.org/en/latest/
alias download-site="wget --recursive --page-requisites --html-extension --convert-links --no-parent"
@nick-merrill
nick-merrill / SelectiveSubviews.m
Last active August 29, 2015 13:56
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.
/*
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];
*/