Skip to content

Instantly share code, notes, and snippets.

@jfahrenkrug
jfahrenkrug / wwdc2013.rb
Last active February 9, 2017 04:38
Ruby Script to check whether WWDC 2013 has been announced.
# in 2013 by Johannes Fahrenkrug, http://springenwerk.com
# See you at WWDC!
require 'rubygems'
require 'open-uri'
class WWDC2013
def self.announced?
begin
indicator_line = open('https://developer.apple.com/wwdc/') do |f|
@cppforlife
cppforlife / gist:1269501
Created October 7, 2011 05:09
objective-c debugging env variables
[schwa@ungoliant] ~$ export OBJC_HELP=1
[schwa@ungoliant] ~$ /Applications/Safari.app/Contents/MacOS/Safari
objc[10559]: Objective-C runtime debugging. Set variable=YES to enable.
objc[10559]: OBJC_HELP: describe available environment variables
objc[10559]: OBJC_PRINT_OPTIONS: list which options are set
objc[10559]: OBJC_PRINT_IMAGES: log image and library names as they are loaded
objc[10559]: OBJC_PRINT_LOAD_METHODS: log calls to class and category +load methods
objc[10559]: OBJC_PRINT_INITIALIZE_METHODS: log calls to class +initialize methods
objc[10559]: OBJC_PRINT_RESOLVED_METHODS: log methods created by +resolveClassMethod: and +resolveInstanceMethod:
objc[10559]: OBJC_PRINT_CLASS_SETUP: log progress of class and category setup
@Overbryd
Overbryd / path-in-mac-osx-10.7.mdown
Created January 24, 2012 09:58
Correcting $PATH in MacOSX 10.7 for homebrew

$PATH in MacOSX 10.7

MacOSX has a truly global path setting that precedes any other setting like ~/.bash_profile. The file /private/etc/paths is a list of pathnames. The order from top to bottom defines the resulting order in the $PATH variable. After loading /private/etc/paths there is a directory /private/etc/paths.d/ with files in the same style. Those are appended to the $PATH variable.

The default content of /private/etc/paths looks like this:

/usr/bin

/bin

// Copyright (c) 2012-2013 Peter Steinberger (http://petersteinberger.com)
//
// 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:
//
// The above copyright notice and this permission notice shall be included in
@krzysztofzablocki
krzysztofzablocki / gist:4091783
Created November 16, 2012 23:13
Free memory on iOS
-(float) get_free_memory {
mach_port_t host_port;
mach_msg_type_number_t host_size;
vm_size_t pagesize;
host_port = mach_host_self();
host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t);
host_page_size(host_port, &pagesize);
vm_statistics_data_t vm_stat;
if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) {
@krzysztofzablocki
krzysztofzablocki / Safe nil calls in server code
Created December 19, 2012 12:36
Simplified check as nil is fine
#define SafeCall(arg, methodToCall) (arg !=[NSNull null]) ? [arg methodToCall] : nil
int optionalValue = SafeCall([response valueForKey:@"number"], intValue);
@krzysztofzablocki
krzysztofzablocki / gist:4396302
Last active November 24, 2021 19:17
Set symbol breakpoint on objc_msgSend then setup this debug command to log all methods called in iOS Simulator. If you want to do device debugging change esp+4 register to r0, esp+8 to r1 Found long ago somewhere on stackoverflow.
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )
@ejknapp
ejknapp / gist:4580156
Created January 20, 2013 17:41
Enable zooming in mobile browsers.
javascript:document.querySelector('meta[name=viewport]').setAttribute('content','width=device-width,initial-scale=1.0,maximum-scale=10.0,user-scalable=1');
@n-b
n-b / selfcompile.m
Last active April 29, 2019 03:43
A simple self-compiling objective-c file
/*/../bin/ls > /dev/null
COMPILED=${0%.*}
clang $0 -o $COMPILED -framework Foundation;
$COMPILED; rm $COMPILED; exit;
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
@steipete
steipete / PSPDFViewController.h
Last active June 6, 2017 03:56
This method will help to prevent a lot of emails about "weird bugs".
// Defines a yet undocumented method to add a warning if super isn't called.
#ifndef NS_REQUIRES_SUPER
#if __has_attribute(objc_requires_super)
#define NS_REQUIRES_SUPER __attribute((objc_requires_super))
#else
#define NS_REQUIRES_SUPER
#endif
#endif
@interface UIViewController (SubclassingWarnings)