Skip to content

Instantly share code, notes, and snippets.

View stuartcarnie's full-sized avatar

Stuart Carnie stuartcarnie

View GitHub Profile
@stuartcarnie
stuartcarnie / UIAlertView_BlocksExtension.h
Created February 20, 2012 05:49
UIAlertView block extension
#import <UIKit/UIKit.h>
@interface UIAlertView (BlocksExtension)<UIAlertViewDelegate>
+ (id)alertViewWithTitle:(NSString *)title message:(NSString *)message completionBlock:(void (^)(NSUInteger buttonIndex))block cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
@end
@stuartcarnie
stuartcarnie / grabmsg.py
Created June 6, 2012 00:30
grab raw messages from gmail / imap
#!/usr/bin/env python
import imaplib
import getpass
import os
import argparse
import sys
__productname__ = 'grabmsg'
__version__ = "0.1"
@stuartcarnie
stuartcarnie / increment_version.py
Created August 2, 2012 22:48
Increment CFBundleVersion of the specified plist file
#!/bin/env python
# Copyright (c) 2012 Stuart Carnie
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
@stuartcarnie
stuartcarnie / main.m
Created September 16, 2012 04:30
tail call with fake msgSend in Objective C
#import <Foundation/Foundation.h>
#import <objc/message.h>
extern id fake_msgSend(id, SEL, int) __attribute__((noinline));
@interface Foo : NSObject
- (id)foo:(int)n;
@end
@stuartcarnie
stuartcarnie / json-pretty
Last active December 17, 2015 17:39
Script to pretty json input
#!/usr/bin/env python
r"""Command-line tool to validate and pretty-print JSON
Usage::
$ echo '{"json":"obj"}' | python -m json.tool
{
"json": "obj"
}
$ echo '{ 1.2:3.4}' | python -m json.tool
@stuartcarnie
stuartcarnie / tsm.ksy
Last active March 25, 2017 23:41
Kaitai Struct definition for InfluxDB .tsm files
meta:
id: tsm
title: InfluxDB TSM file
license: MIT
file-extension: tsm
endian: be
seq:
- id: header
type: header
@stuartcarnie
stuartcarnie / influxql.ebnf
Last active May 17, 2017 00:53
EBNF for InfluxQL
// queries
query ::= statement ( ";" statement )*
statement ::= alter_retention_policy_stmt |
create_continuous_query_stmt |
create_database_stmt |
create_retention_policy_stmt |
create_subscription_stmt |
create_user_stmt |
@stuartcarnie
stuartcarnie / .zshrc
Last active August 7, 2020 01:43
My standard .zshrc with oh-my-zsh
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="juanghurtado"
@stuartcarnie
stuartcarnie / LICENSE.txt
Last active July 11, 2021 18:30
Clang API notes schema definition
Copyright 2020 Stuart Carnie
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
@stuartcarnie
stuartcarnie / main.m
Created March 4, 2011 19:59
Demonstrates we can now support limited JIT compilation on recent versions of iOS (assuming Apple approves entitlements at some future point)
//
// main.m
// ProtectTest
// Demonstrates newer versions of iOS now support PROT_EXEC pages, for just-in-time compilation.
//
// Must be compiled with Thumb disabled
//
// Created by Stuart Carnie on 3/4/11.
// Copyright 2011 Manomio LLC. All rights reserved.
//