Skip to content

Instantly share code, notes, and snippets.

@asif-mistry
asif-mistry / NSApplication+SelfRelaunch.m
Created May 4, 2018 11:12 — forked from cdfmr/NSApplication+SelfRelaunch.m
Self relaunch of Cocoa application
@implementation NSApplication (Relaunch)
- (void)relaunchAfterDelay:(float)seconds
{
NSTask *task = [[[NSTask alloc] init] autorelease];
NSMutableArray *args = [NSMutableArray array];
[args addObject:@"-c"];
[args addObject:[NSString stringWithFormat:@"sleep %f; open \"%@\"", seconds, [[NSBundle mainBundle] bundlePath]]];
[task setLaunchPath:@"/bin/sh"];
[task setArguments:args];
@asif-mistry
asif-mistry / Swift 4 - NSApp Relaunch.swift
Created May 4, 2018 11:12 — forked from KyLeggiero/Swift 4 - NSApp Relaunch.swift
Allows you to re-launch a Cocoa app
import Cocoa
extension NSApplication {
func relaunch(afterDelay seconds: TimeInterval = 0.5) -> Never {
let task = Process()
task.launchPath = "/bin/sh"
task.arguments = ["-c", "sleep \(seconds); open \"\(Bundle.main.bundlePath)\""]
@asif-mistry
asif-mistry / Remove_MIUI_Bloatware.bat
Created June 9, 2018 18:27
Batch file to remove preinstalled bloated apps in MIUI devices with ADB
@echo off
set /p Y=Enter adb.exe folder path:
cd %Y%
adb devices
pause
for %%X in (
"com.android.browser"
"com.android.chrome"
"com.android.email"
"com.android.thememanager"
@asif-mistry
asif-mistry / AutoDescribingObjects.swift
Last active June 26, 2018 08:41 — forked from YogevSitton-zz/AutoDescribingObjects.swift
Use auto-describing objects with CustomStringConvertible
extension CustomStringConvertible {
var description : String {
var description: String = ""
if self is AnyObject {
//description = "***** \(type(of: self)) - <\(unsafeAddressOf((self as! AnyObject)))>***** \n"
} else {
description = "***** \(type(of: self)) *****\n"
}
let selfMirror = Mirror(reflecting: self)
for child in selfMirror.children {
@asif-mistry
asif-mistry / DeviceUID.m
Last active October 18, 2018 08:49 — forked from miguelcma/DeviceUID.m
iOS Unique Device ID that persists between app reinstalls
/* DeviceUID.h
#import <Foundation/Foundation.h>
@interface DeviceUID : NSObject
+ (NSString *)uid;
@end
*/
// Device.m