Skip to content

Instantly share code, notes, and snippets.

import UIKit
class MyViewController: UIViewController {
@IBOutlet weak var button: UIButton!
var vc: UIViewController? = nil
override func viewDidLoad() {
super.viewDidLoad()
button.addTarget(self, action: #selector(down), for: .touchDown)
//Copyright (c) 2018 Michael Eisel. All rights reserved.
#import <Foundation/Foundation.h>
// Returns all the calls that have been made, in the order that they were made. If a call is made more than once, it just records the first instance.
// Each time this function is called, it returns only the calls that have been made since the last time it was called
extern NSArray <NSString *> *CLRCollectCalls(void);
//Copyright (c) 2018 Michael Eisel. All rights reserved.
#import "CLRCallRecorder.h"
#import <dlfcn.h>
#import <libkern/OSAtomicQueue.h>
#import <pthread.h>
typedef struct {
void *ptr;
NSInteger number;
#import "ViewController.h"
@interface ViewController ()
@end
@interface asdf : NSObject
@end
- (void)dealloc
{
if (_shouldRecycle) {
objc_destructInstance(self);
[self recycle];
} else {
[super dealloc];
}
}
#!/usr/bin/ruby
require 'mechanize'
require 'parallel'
def should_follow_url(h)
return [
h.size > 0,
!h.include?(".."),
!h.include?("//"),
-(id)retain
{
NSIncrementExtraRefCount(self);
return self;
}
-(void)release
{
if(NSDecrementExtraRefCountWasZero(self))
{
import Foundation
import UIKit
class ViewPool {
private var freeViews: [UIView] = []
private var allViews: [UIView] = []
init() {
}
// in asm_atoi.S...
fbld (%rdi)
fstpl -8(%rbp)
movq -8(%rbp), %xmm0
// in main.c...
int main(int argc, const char * argv[]) {
const char *c = "2384";
char b[10] = {0};
for (int i = 0; i < sizeof(c); i++) {
// Note that this checker is always running, even when the app is in the background (where it doesn't matter if the main thread is blocked)
// You'll have to add more code if you don't want the checker to run while the app is in the background
final class ANRChecker {
private let ANRThreshold: CFTimeInterval = 5
// This variable may be accessed from multiple threads at the same time. It won't cause issues, but if you want prevent the thread sanitizer from complaining, you can add locking around it or w/e
private lazy var lastResponseTime: CFTimeInterval = CACurrentMediaTime()
func beginChecking() {
updateLastResponseTime()