Skip to content

Instantly share code, notes, and snippets.

View itod's full-sized avatar

Todd Ditchendorf itod

View GitHub Profile
@holtwick
holtwick / HORegExp.h
Last active September 25, 2021 02:11
ObjC RegExp Helper with rudimentary named groups
// Copyright 2012 Dirk Holtwick, holtwick.it. All rights reserved.
@import Foundation;
#define HORegexDefaultOptions NSRegularExpressionCaseInsensitive | NSRegularExpressionAnchorsMatchLines | NSRegularExpressionAllowCommentsAndWhitespace
@interface HORegexMatch : NSTextCheckingResult
@property (readonly, nonatomic) NSString *text;
@property (readonly, nonatomic) NSTextCheckingResult *match;
@grigb
grigb / MacMailToCSV.py
Last active September 10, 2018 03:06
Convert an exported Mac Mail mbox file into CSV for data mining
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# assumes your file is called mbox
# writes to a file called mbox.csv
import mailbox
import csv
@regexident
regexident / 0000-HashVisitable.md
Last active October 12, 2017 09:00
Swift Evolution Proposal Draft for replacing `Hashable` with `Hasher` and `HashVisitable`.

HashVisitable

During the review process, add the following fields as needed:

Introduction

# pragma mark Custom caret
- (void)drawInsertionPointInRect:(NSRect)aRect color:(NSColor *)aColor turnedOn:(BOOL)flag {
aRect.size.width = self.caretWidth;
[super drawInsertionPointInRect:aRect color:aColor turnedOn:flag];
}
// This is a hack to get the caret drawing to work. I know, I know.
- (void)setNeedsDisplayInRect:(NSRect)invalidRect {
invalidRect.size.width += self.caretWidth - 1;
@gcko
gcko / related.py
Last active August 7, 2023 09:32
Django Custom Model ForeignKey Field for Spanning Databases
@NickChristensen
NickChristensen / gmail-inbox-count-terse.js
Last active December 30, 2018 22:30
Userscript for http://fluidapp.com: Sets dock badge to inbox count
window.fluid.dockBadge = '';
setTimeout(updateDockBadge, 1000);
setTimeout(updateDockBadge, 3000);
setInterval(updateDockBadge, 5000);
function updateDockBadge() {
window.fluid.dockBadge = document.querySelector('[title^="Inbox"]').title.match(/\d+/);
}
@kevshub
kevshub / fluid_gmail.js
Last active November 21, 2016 03:59 — forked from kirbysayshi/fluid_gmail.js
- Removed duplicate timers - Added a remove badge option - Added (Advanced) Growl Notifications, # of new emails and # of unread messages. - Only notify when email counter goes up not down - Added sound notification
window.fluid.dockBadge = '';
function updateDockBadge() {
console.log('check new messages');
var navigation = document.querySelector('[role=navigation]')
var doc = navigation.contentDocument || navigation.ownerDocument;
if (!doc) { return; }
@itod
itod / remove_prefix.applescript
Last active November 21, 2016 03:56
AppleScript to remove a common prefix from the name of all files in a given folder.
set path_ to (get path to desktop as string) & "FOLDER NAME HERE"
set prefix_ to "PREFIX HERE"
tell application "Finder"
set dir_ to folder path_
set files_ to items of dir_ whose name of it starts with prefix_
set start_ to (get length of prefix_) + 1
repeat with file_ in files_
set oldname_ to name of file_
set end_ to length of oldname_
@lilyball
lilyball / gist:3373169
Created August 16, 2012 20:04
objc_cast
template<typename T> inline T* objc_cast(id from) {
if ([from isKindOfClass:[T class]]) {
return static_cast<T*>(from);
}
return nil;
}
@romac
romac / Increment Digits In Selected Text.php
Created June 17, 2010 11:50
Two Commands for TextMate which allows you to increment any digits/numbers in the selected text.
#!/usr/bin/env php
<?php
$text = $_ENV[ 'TM_SELECTED_TEXT' ];
print preg_replace_callback(
'/(\d)/',
function( $matches )
{
return $matches[ 0 ] + 1;