This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static $instance; | |
public static function get_instance() { | |
$class = get_class(this); | |
if(!self::$instance) | |
self::$instance = new $class(); | |
return self::$instance; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var width = 320; //default to non-retina iPhone | |
var height = 460; | |
if(navigator.platform === 'iPad') { | |
if(window.orientation === 90 || window.orientation === -90) { | |
width = 1024; //landscape | |
height = 748; | |
} | |
else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api=http://ajax.googleapis.com/ajax/services/search/web?v=1.0 | |
url=$(curl -s --get --data-urlencode "q=$1" $api | | |
sed 's|"unescapedUrl":"\([^"]*\).*|\1|;s|.*GwebSearch",||') | |
echo -n $url | pbcopy | |
echo $url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ `defaults read com.apple.finder AppleShowAllFiles` == 1 ] | |
then | |
defaults write com.apple.finder AppleShowAllFiles -bool false | |
else | |
defaults write com.apple.finder AppleShowAllFiles -bool true | |
fi | |
killall Finder |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "System Events" | |
set itunesRunning to count of (every process whose name is "iTunes") | |
if itunesRunning is 0 then return | |
end tell | |
tell application "iTunes" | |
if player state is stopped then return | |
set shows to {{title:"Hypercritical", slug:"hypercritical"}, {title:"The Talk Show", slug:"talkshow"}, {title:"Build and Analyze", slug:"buildanalyze"}, {title:"After Dark", slug:"afterdark"}, {title:"The Pipeline", slug:"pipeline"}, {title:"5by5 Specials", slug:"specials"}, {title:"Back To Work", slug:"b2w"}, {title:"Mac Power Users", slug:"mpu"}, {title:"The Incomparable", slug:"incomparable"}, {title:"The Cocktail Napkin", slug:"tcn"}, {title:"Latest in Paleo", slug:"paleo"}, {title:"Critical Path", slug:"criticalpath"}, {title:"The Big Web Show", slug:"bigwebshow"}, {title:"Content Talks", slug:"contenttalks"}, {title:"Founders Talk", slug:"founderstalk"}, {title:"The Ihnatko Almanac", slug:"ia"}, {title:"Geek Friday", slug:"geekfriday"}, {title:"Internet Superhero", slug:"superhero"}, {title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Finder" | |
set dlApps to every file in (path to downloads folder) whose name extension is "app" | |
repeat with newApp in dlApps | |
move newApp to (path to applications folder) with replacing | |
end repeat | |
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Safari" to set currentURL to URL of current tab of window 1 | |
tell application "Google Chrome" | |
activate | |
delay 0.2 | |
if (exists window 1) and (URL of active tab of window 1 is "chrome://newtab/") then | |
tell window 1 to set URL of active tab to currentURL | |
else | |
open location currentURL | |
end if | |
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; | |
NSArray *subviews = [cell.contentView subviews]; | |
for(UIView *subview in subviews) { | |
if([subview isKindOfClass:[UITextField class]] || [subview isKindOfClass:[UITextView class]]) { | |
[subview becomeFirstResponder]; | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-(BOOL)textFieldShouldReturn:(UITextField*)textField; | |
{ | |
NSInteger nextTag = textField.tag + 1; | |
UIResponder *nextResponder = [self.view viewWithTag:nextTag]; | |
if(nextResponder) { | |
[nextResponder becomeFirstResponder]; | |
} | |
else { | |
[self.view endEditing:YES]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)selectParentTableViewCell:(UIView *)view | |
{ | |
//maximum 5 attempts | |
for(int i = 0; i < 5; i++) { | |
view = view.superview; | |
if([view isKindOfClass:[UITableViewCell class]]) { | |
UITableViewCell *cell = (UITableViewCell *)view; | |
[self.tableView selectRowAtIndexPath:[self.tableView indexPathForCell:cell] animated:NO scrollPosition:UITableViewScrollPositionNone]; | |
break; | |
} |
OlderNewer