Skip to content

Instantly share code, notes, and snippets.

@curthard89
curthard89 / gist:1183218
Created August 31, 2011 10:02
Word Count for NSString
- (NSInteger)wordCount
{
NSInteger length = [self length];
NSRange inputRange = NSMakeRange( 0, length );
NSInteger count = 0;
while( YES )
{
NSRange range = [self rangeOfCharacterFromSet:[NSCharacterSet whitespaceCharacterSet]
options:NSCaseInsensitiveSearch
range:inputRange];
//
// NSReadability.m
// Caffeinated
//
// Created by Curtis Hard on 19/08/2011.
// Copyright 2011 GeekyGoodness. All rights reserved.
//
#import "GGReadability.h"
/*
Copyright (c) 2011 Curtis Hard - GeekyGoodness
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
the following conditions:
if( [bottomButtons count] != 0 )
{
NSMutableArray * newArray = [[[NSMutableArray alloc] init] autorelease];
for( NSInteger i = [bottomButtons count] - 1; i >= 0; i-- )
{
[newArray addObject:[bottomButtons objectAtIndex:i]];
}
float startY = 0.0 + ( CAFF_POPUP_SHADOW_PADDING + CAFF_POPUP_PADDING + CAFF_POPUP_ARROW_HEIGHT );
float startX = 0.0 + ( CAFF_POPUP_SHADOW_PADDING + CAFF_POPUP_PADDING + CAFF_POPUP_ARROW_HEIGHT );
- (void)refreshFavicons:(NSArray *)subscriptions
force:(BOOL)flag
{
LOGGED_IN
for( GDataSubscription * subscription in subscriptions )
{
if( ! flag && [[self delegate] respondsToSelector:@selector(gDataController:checkFaviconExistanceForSubscription:)] )
{
if( [[self delegate] gDataController:self
void NSAnimationContextRunAnimationBlock( dispatch_block_t group, dispatch_block_t completionHandler, NSTimeInterval time )
{
[NSAnimationContext runAnimationBlock:group
completionHandler:completionHandler
duration:time];
}
+ (void)runAnimationBlock:(dispatch_block_t)group
completionHandler:(dispatch_block_t)completionHandler
duration:(NSTimeInterval)time
<?php
class lib_coredata_predicate extends lib_coredata_properties
{
/**
*
*/
const LIB_COREDATA_FILLER_ATTRIBUTE = '%@';
$this->set_request( lib_coredata_request::factory( lib_coredata_entity::factory( 'news' ) )
->set_predicate( new lib_coredata_predicate( 'status=%d', 5 ) ) );
//
// GDataController.m
// Caffeinated
//
// Created by Curtis Hard on 03/11/2010.
// Copyright (c) 2010 GeekyGoodness. All rights reserved.
//
#import "GDataController.h"
+ (UniChar)characterForVirtualKeyCode:(NSInteger)keyCode
{
/**************
THIS REQUIRES THE CARBON FRAMEWORK!
***************/
UInt32 deadKeyState = 0;
UniCharCount actualCount = 0;
UniChar baseChar;
TISInputSourceRef sourceRef = TISCopyCurrentKeyboardLayoutInputSource();
CFDataRef keyLayoutPtr = (CFDataRef)TISGetInputSourceProperty( sourceRef, kTISPropertyUnicodeKeyLayoutData );