Skip to content

Instantly share code, notes, and snippets.

View billymeltdown's full-sized avatar

Billy Gray billymeltdown

View GitHub Profile
@billymeltdown
billymeltdown / ZTTableViewController.m
Last active January 13, 2016 21:17
NSCell - still the best way to calculate dynamic row height for wrapping text in an NSView-based NSTableView?
- (CGFloat)tableView:(NSTableView *)tableView heightOfRow:(NSInteger)row {
CGFloat minimumHeight = 20.0f;
// check the cache to avoid unnecessary recalculation
NSNumber *cachedHeight;
ZTObject *field = [self.fields objectAtIndex:row];
NSString *cacheKey = [field identifier];
if ((cachedHeight = [self.cellRowHeightsCache objectForKey:cacheKey])) {
return [cachedHeight floatValue];
Process: MySuperApp [2634]
Path: /Applications/MySuperApp.app/Contents/MacOS/MySuperApp
Identifier: net.zetetic.MySuperApp.mac
Version: 2.0.2 (2.0.2)
Code Type: X86-64 (Native)
Parent Process: launchd [193]
Date/Time: 2013-07-09 17:56:26.539 -0400
OS Version: Mac OS X 10.6.8 (10K549)
Report Version: 6
@billymeltdown
billymeltdown / gist:5510304
Created May 3, 2013 15:58
Example of taking data from an iOS accelerometer and using it to seed OpenSSL's RAND.
- (void)seedFromAcceleration:(UIAcceleration *)accel {
UIAccelerationValue value = accel.x;
RAND_add(&value, sizeof(value), sizeof(value));
value = accel.y;
RAND_add(&value, sizeof(value), sizeof(value));
value = accel.z;
RAND_add(&value, sizeof(value), sizeof(value));
NSTimeInterval interval = accel.timestamp;
RAND_add(&interval, sizeof(interval), sizeof(interval));
Crashed Thread: 5 Dispatch queue: com.apple.root.default-priority
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000000
VM Regions Near 0:
-->
__TEXT 0000000100000000-00000001002e6000 [ 2968K] r-x/rwx SM=COW /Applications/Strip.app/Contents/MacOS/Strip
Thread 0:: Dispatch queue: com.apple.main-thread
@billymeltdown
billymeltdown / gist:4169422
Created November 29, 2012 14:24
Can run afoul of cross-device link error
NSURL *remoteFileURL = [[self temporaryDocumentsURL] URLByAppendingPathComponent:ZTDropboxRemoteFileName];
NSURL *databaseFileURL = [[self dropboxFolderURL] URLByAppendingPathComponent:self.dbFileName];
NSError *error;
BOOL success = NO;
NSFileManager *fm = [NSFileManager defaultManager];
// if this isn't our first time, use replaceItem...
if ([databaseFileURL checkResourceIsReachableAndReturnError:&error])
{
NSURL *newItemURL;
success = [fm replaceItemAtURL:databaseFileURL
@billymeltdown
billymeltdown / export_radiant_comments_to_disqus.rb
Created December 19, 2010 20:11
Exports Radiant CMS's comments extension data to a WXR XML file for import into Disqus
BLOG_PARENT_ID = 4
xml = Builder::XmlMarkup.new(:target => STDOUT, :indent => 2)
xml.instruct!
xml.rss(
:version => '2.0',
'xmlns:excerpt' => "http://wordpress.org/export/1.0/excerpt/",
'xmlns:content' => "http://purl.org/rss/1.0/modules/content/",
'xmlns:wfw' => "http://wellformedweb.org/CommentAPI/",
'xmlns:dc' => "http://purl.org/dc/elements/1.1/",
'xmlns:wp' => "http://wordpress.org/export/1.0/"
@billymeltdown
billymeltdown / oamPageSentry-apex4.sql
Created December 10, 2010 15:52
Zetetic's customized version of Oracle's page sentry to account for session ID discrepancy in Apex 4.0
CREATE OR REPLACE function PASSPORT.oamPageSentry ( p_apex_user in varchar2 default 'APEX_PUBLIC_USER' )
return boolean
as
l_cgi_var_name varchar2(100) := 'REMOTE_USER';
l_authenticated_username varchar2(256) := upper(owa_util.get_cgi_env(l_cgi_var_name));
--
l_current_sid number;
l_url_sid varchar2(4000);
l_url varchar2(4000);
l_app_page varchar2(4000);
@billymeltdown
billymeltdown / oamPageSentry-apex3.sql
Created December 10, 2010 15:31
Zetetic's custom oamPageSentry function for APEX 3.0
CREATE OR REPLACE FUNCTION PASSPORT.oamPageSentry(pUser IN VARCHAR2 DEFAULT 'APEX_PUBLIC_USER') RETURN BOOLEAN
IS
vUsername VARCHAR2(512);
vSession NUMBER;
BEGIN
-- extract user from HTTP header
vUsername := UPPER(owa_util.get_cgi_env('REMOTE_USER'));
-- extract session id
vSession := wwv_flow_custom_auth_std.get_session_id_from_cookie;
- (void)startObserving
{
// start observing the entriesController's selection property,
// so we can properly update the third pane with a populated
// entry view once an entry is selected
[entriesController addObserver:self
forKeyPath:@"selection"
options:NSKeyValueObservingOptionNew
context:EntryWindowContext];
}
module SiteHelper
attr_accessor :content_hash
def content_hash
@content_hash ||= {}
end
def yield_for(index)
output = self.content_hash[index.to_sym]
output = "" if output.nil?
output