Skip to content

Instantly share code, notes, and snippets.

// save the info system button image to where you can access it, this should be able to
// go anywhere it gets run by an iPhone program, easiest if you do it with the simulator
UIButton *info = [UIButton buttonWithType:UIButtonTypeInfoLight];
NSData *img = UIImagePNGRepresentation([info imageForState:UIControlStateNormal]);
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"info.png"];
[img writeToFile:path atomically:NO];
NSLog(@"%@", path);
- (NSString *) base64EncodingWithLineLength:(unsigned int) lineLength data:(NSData *)imgData {
static const char *encodingTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
const unsigned char *bytes = [imgData bytes];
NSMutableString *result = [NSMutableString stringWithCapacity:[imgData length]];
unsigned long ixtext = 0;
unsigned long lentext = [imgData length];
long ctremaining = 0;
unsigned char inbuf[3], outbuf[4];
short i = 0;
iOsScrollingToggle : function(enabled){
function preventScroll(e){
e.preventDefault();
e.stopPropagation();
}
// This should prevent people from scrolling away from the modal window without closing it
if(enabled){
document.body.removeEventListener('touchmove',preventScroll,false);
} else {
document.body.addEventListener('touchmove',preventScroll,false);
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily) {
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray: [UIFont fontNamesForFamilyName: [familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont) {
NSLog(@"Font name: %@", [fontNames objectAtIndex:indFont]);
}
[fontNames release];
<!-- Sample usage: http://localhost/convert/gist.github.com/gists/128733 -->
<!-- Hardcoded charset bug to be sorted out yet -->
<?php $f = file("http://".$_SERVER['QUERY_STRING']); ?>
<?php header("Content-type: text/html; charset=cp1251"); ?>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
<style> body { width: 320px !important; } nobr {white-space: normal !important; } dd { margin: 5px 10px;} </style>
<?php echo implode($f, "") ?>
NSString *id = [[UIDevice currentDevice] uniqueIdentifier];
#if TARGET_IPHONE_SIMULATOR
NSLog(@"Some debugging");
#else
// Do nothing!
#end
(function($) {
var userAgent = navigator.userAgent.toLowerCase();
$.extend($.browser, {
iphone: $.browser.safari && /iphone/.test(userAgent),
chrome: $.browser.safari && /chrome/.test(userAgent)
});
})(jQuery);
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[self.window addSubview:self.splitVC.view];
} else {
[self.window addSubview:self.navigationController.view];
}
[self.window makeKeyAndVisible];
return YES;
UIApplication sharedApplication].idleTimerDisabled = YES;