Skip to content

Instantly share code, notes, and snippets.

View username0x0a's full-sized avatar
🐵
🙉 🙈 🙊

Michal Zelinka username0x0a

🐵
🙉 🙈 🙊
View GitHub Profile
@username0x0a
username0x0a / iOS-resetAppData-in-AppDelegate.m
Last active November 22, 2020 18:12
App Delegate method allowing you to wipe all app data on demand
#define NSDocumentsDirectory() [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
#define NSLibraryDirectory() [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES) firstObject]
#define NSCachesDirectory() [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
//efine NSTemporaryDirectory() Not needed - defined in Foundation
@implementation AppDelegate
- (void)performDataReset
{
// Clean-up all data folders...
@username0x0a
username0x0a / UIDevice+faceColor.m
Last active November 22, 2020 18:13
UIDevice extension to identify the front face colour of your device
typedef NS_ENUM(NSUInteger, UIDeviceFaceColor) {
UIDeviceFaceColorUnknown = 0,
UIDeviceFaceColorBlack,
UIDeviceFaceColorWhite,
};
...
@implementation UIDevice (Utils)
@username0x0a
username0x0a / UIDevice+cellularCarrierDisplayedName.m
Last active November 22, 2020 18:13
UIDevice subclass for fetching real carrier display name – may differ from regular -carrierName for virtual operators etc.
@implementation UIDevice (Utils)
- (NSString *)cellularCarrierName
{
return [[[[CTTelephonyNetworkInfo alloc] init] subscriberCellularProvider] carrierName];
}
- (NSString *)cellularCarrierDisplayedName
{
static NSString *displayedName = nil;
@username0x0a
username0x0a / xcodesrv-github-post.rb
Last active November 22, 2020 18:12
Xcode Server post-integration script allowing commit status updates on Github using Github Statuses API
#!/usr/bin/env ruby
require 'fileutils'
require 'json'
result = ENV["XCS_INTEGRATION_RESULT"].to_s
exit if result == 'canceled'
path = ENV["XCS_SOURCE_DIR"].to_s + '<<repo_name>>'
FileUtils.cd path
@username0x0a
username0x0a / SKStoreReviewDummyClass.m
Last active November 22, 2020 18:13
Dummy class easing detection whether the native StoreKit in-app Review alert has been fired or not. Useful as a callback when firing the limited system rating alert.
@interface SKStoreReviewDummyClass : NSObject @end
@implementation SKStoreReviewDummyClass
+ (void)load
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class class = [self class];
@username0x0a
username0x0a / ClientServer.ShortMessages.playground.swift
Last active November 22, 2020 18:13
A set of classes useful for discovering devices in a local network via Bonjour and sending short messages.
//: Playground - noun: a place where people can play
import Cocoa
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
let BUFFER_SIZE = 1024
let SERVICE_TYPE = "_myservice._tcp"
let SERVICE_DOMAIN = "local"
@username0x0a
username0x0a / lldb_01.txt
Last active November 22, 2020 18:12 — forked from TheFox/lldb_01.txt
Cracking Hopper App
:> lldb Hopper.app
lldb:> target create "Hopper.app"
error: unable to find CIE at 0xf1bf1410 for cie_id = 0x0e410000 for entry at 0x00001404.
error: unable to find CIE at 0xfb722890 for cie_id = 0x048e0583 for entry at 0x00002e0f.
Current executable set to 'Hopper.app' (x86_64).
lldb:> run
Process 86127 launched: 'Hopper.app' (x86_64)
Process 86127 exited with status = 45 (0x0000002d)
@username0x0a
username0x0a / normalize_simulator_frame.applescript
Last active November 22, 2020 18:13
iOS Simulator frame normalizing script – helps keeping your Xcode 9.1+ Simulator windows in sane and effective sizes!
tell application "Simulator" to activate -- needs to be in front
tell application "System Events" to tell application process "Simulator"
try
repeat with wnd in windows
set t to name of wnd
set tbh to 22 -- toolbar height
if t contains "iPhone X" then
set size of wnd to {375, 812 + tbh}
else if t contains "iPhone" and t contains "Plus" then
set size of wnd to {414, 736 + tbh}
@username0x0a
username0x0a / enforcevpnhost.rb
Last active November 22, 2020 18:12
Simple macOS Ruby script allowing to enforce VPN use for specified IPs and hostnames in case you're not into sending all your traffic via the connected VPN
#!/usr/bin/env ruby
# Check for arguments
def check_ip_ip_range(inp)
return inp =~ /^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\/[0-9]{1,2})?$/ ? true : false
end
if ARGV.count < 1 then
puts "Usage: enforcevpnhost [ip4|ip4net|hostname]"
@username0x0a
username0x0a / FoundationMutabilityType.m
Last active November 22, 2020 18:12
Very useful macro to get around some mutable/immutable assignment issues for basic Foundation types.
#import <Foundation/Foundation.h>
@interface NSString (FoundationMutabilityType)
- (NSString *)copy;
- (NSMutableString *)mutableCopy;
@end