Skip to content

Instantly share code, notes, and snippets.

@antmd
antmd / gist:771683
Created January 9, 2011 13:32
Perl starter for iterating over a file from either a supplied filename or stdin
#!/usr/bin/perl -w
use strict;
my $input = *STDIN;
if(scalar @ARGV) {
open(FH,$ARGV[0]);
$input = *FH;
}
@antmd
antmd / urlchanger.m
Created January 9, 2011 13:48
Example of lifting a monadic block into a function that operates on an NSArray
//
// main.m
// URLChanger
//
//
#import <Foundation/Foundation.h>
typedef NSArray* (^LiftedFunctor)(id<NSFastEnumeration>) ;
typedef id (^Functor)(id);
@antmd
antmd / makefile
Created January 9, 2011 13:52
Example makefile for building Objective-C and Objective-C++ command-line tools
all:commonprefix
clean:
rm *.o urlchanger
CC=clang
CFLAGS+=-O0 -g
CXXFLAGS+=-O0 -g
@antmd
antmd / gist:3866000
Created October 10, 2012 14:32
pathmunge
# Pathmunge -- add a new path to a path variable
# arg1 - name of path variable
# arg2 - new path to add
# arg3 - if present APPEND rather than PREPEND
pathmunge () {
local pathVar=$1
local pathVal=$(eval echo \$$pathVar)
local newVal=$2
local after=$3
#!/usr/bin/python
__author__ = 'ant'
"""
Generate a C-function to convert an enum value into an NSString, and put it on the clipboard
Note, only handles NS_ENUM style enums at the moment.
"""
import sys
import re
@antmd
antmd / .lldbinit
Created September 23, 2013 19:38 — forked from mayoff/.lldbinit
command script import ~/Library/lldb/sniff_objc_exception_throw.py
@antmd
antmd / clangsinglecompile.sh
Created November 21, 2013 21:46
Script to compile a single Objective-C file
#!/bin/bash -
set -o nounset # Treat unset variables as an error
SRC=$1
SRCROOT=${SRC%.*}
TMPFILE=`mktemp /tmp/singlecompile.XXXXXX` || exit 1
PRODUCTS_DIR=~/Development/Products
FRAMEWORKS_BUILD_TYPE=Debug
@antmd
antmd / fps.sh
Created November 23, 2013 18:29
Find processes matching name
#!/bin/bash
if [ $# -lt 1 ]; then
exit 1
fi
PROG_NAME=$1
PROGS=$(ps -u$USER -eww -opid,ucomm | grep -i $PROG_NAME | grep -v grep | tr '\n' ':')
@antmd
antmd / drawit.md
Created November 30, 2013 10:53
drawIt Keyboard Shorcuts

\di to start DrawIt and \ds to stop DrawIt.

The alpha/beta version is available at http://www.drchip.org/astronaut/vim/index.html#DRAWIT.

the ellipse and \e to trigger the ellipse drawing.

DrawIt incorporates an "erase" mode, toggled by the key, that will leave a trail of blanks behind and under the cursor as it is moved by the number pad. Using the shift-arrow keys, DrawIt will move the cursor, expanding lines and inserting spaces as needed, without changing underlying text.

I was chasing down another issue (slow "Save As") and thought these two issues may have been related (with QuickLook being the common broken link). Unfortunately, my "Save As" dialog is still miserably slow on the initial load; but IconServicesAgent hasn't gone above 30MB and he rarely makes an appearance in the Console!

Some of these steps may not be necessary, but here are all of the steps I took that inadverdently put IconServicesAgent back in its place. Note: all commands are a single-line, if they appear to be multiple that's just the forum formatting.

  1. Check for any QuickLooks related .plist files. In a terminal: mdfind com.apple.quicklook. -name .plist

  2. I only had files at the system level (specifically within /System/Library/LaunchAgents/). If you have others, modify the directions below to take that into account (re-introducing plist files from the system level back up to the user).

  3. Make some temporary directories to store these plist files, just in case: mkdir ~/tmp-quicklook