Skip to content

Instantly share code, notes, and snippets.

<?php
public function __call($method, $arguments) {
$realMethodName = "_" . $method;
if (method_exists($this, $realMethodName)) {
$response = $this->callOldVersion($arguments);
let types = UIUserNotificationSettings(forTypes: [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(types)
UIApplication.sharedApplication().registerForRemoteNotifications()
//Load a nib with a given name
class func loadFromNibNamed(nibNamed: String, bundle : NSBundle = NSBundle.mainBundle()) -> UIView! {
return UINib(nibName: nibNamed, bundle: bundle).instantiateWithOwner(nil, options: nil)[0] as? UIView
}
<?php
while (true) {
//poll database
//send messages over XMPP connection
//take a nap
sleep(5);
}
<?php
//Initialize
$this->client = new JAXL(array(
'jid' => $this->senderId .'@gcm.googleapis.com',
'pass' => $this->googleApiKey,
'auth_type' => 'PLAIN',
'host' => $this->host,
'port' => $this->port,
'strict' => false,
enum PAGE_STATE { INITIALIZING, LOADING, LOADED, NETWORK_ISSUES }
PAGE_STATE currentState = PAGE_STATE.INITIALIZING;
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
//stuff to run on the main thread
}
});
if (adapter == null) {  
adapter = new PhotoAdapter(getChildFragmentManager());
}
adapter.clearCache();
pager.setAdapter(adapter);
Boolean clearCache = false;
public void clearCache() {
mFragments.clear();
clearCache = true;
}
if (mAdapter != null) {
mAdapter.restoreState(ss.adapterState, ss.loader);
setCurrentItemInternal(ss.position, false, true);
}