Skip to content

Instantly share code, notes, and snippets.

View stith's full-sized avatar

Anna Stith stith

View GitHub Profile
@stith
stith / grep-find-files-containing-text.sh
Created November 19, 2009 02:54
Random command line snippets
grep -lir "some text" *
// -l outputs only names of files containing text instead of the line
// -i ignores case
// -r recursive, go into subdirectories
@stith
stith / dice.txt
Created January 4, 2010 14:27
Cleverbot conversations
User: Will you roll a dice, please?
Cleverbot: I don't understand your request.
User: Roll a dice.
Cleverbot: Four.
User: Roll a dice.
def allocated_date=(new_value)
write_attribute(:allocated_date, new_value) unless read_attribute(:allocated_date)
end
@stith
stith / aasm_test.rb
Created March 4, 2010 09:52
Ruby test cases for testification
#!/usr/bin/env ruby
# Testing the aasm gem to see how to get one aasm_event to decide
# which state to transition into
require 'rubygems'
require 'aasm'
class TestObject
include AASM
aasm_initial_state :active
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"name = %@",someVariableNameLol];
NSArray *filteredArray = [friends filteredArrayUsingPredicate:predicate];
Product Names Guidelines
You may use Apple, iPad, or any other Apple word mark (but not the Apple Logo or other Apple-owned graphic symbol/logo) in a referential phrase on packaging or promotional/advertising materials to describe that the third party product is compatible with the referenced Apple product or technology, provided they comply with the following requirements.
a. The Apple word mark is not part of the product name.
b. The Apple word mark is used in a referential phrase such as "runs on," "for use with," "for," or "compatible with."
c. The Apple word mark appears less prominent than the product name.
d. The product is in fact compatible with, or otherwise works with, the referenced Apple product.
e. The reference to Apple does not create a sense of endorsement, sponsorship, or false association with Apple or Apple products or services.
f. The use does not show Apple or its products in a false or derogatory light.
@stith
stith / debug.m
Created January 3, 2011 02:12
MSLog code
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Debug
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#define DEBUG_ON // Toggle to DEBUG_OFF or comment out to hide all debug code
#ifdef DEBUG_ON
#define MSLog(format, ...) CFShow([[NSString stringWithFormat:@"<%@:%d> ",[[NSString stringWithUTF8String:__FILE__] lastPathComponent],__LINE__] stringByAppendingFormat:format, ## __VA_ARGS__])
#else
#define MSlog(format, ...)
#endif
// Info button
UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
infoButton.frame = CGRectMake(290, 300, 20, 20);
[infoButton addTarget:self action:@selector(infoTapped:) forControlEvents:UIControlEventTouchUpInside];
[infoButton setEnabled:YES];
[containerView addSubview:infoButton];
[containerView bringSubviewToFront:infoButton];
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# timegrep.py by Dennis Williamson 20100113
# in response to http://serverfault.com/questions/101744/fast-extraction-of-a-time-range-from-syslog-logfile
# thanks to serverfault user http://serverfault.com/users/1545/mike
# for the inspiration
# Perform a binary search through a log file to find a range of times
# and print the corresponding lines
@stith
stith / engineswap.php
Created May 4, 2011 04:40
Mass MySQL storage engine updater
<?php
// Update tables from one storage engine to another
//
// Written by Matt Stith for Nexcess.net
// May 3, 2011
//
// CLI only
if (!defined('STDIN')) {