Skip to content

Instantly share code, notes, and snippets.

@kylehowells
kylehowells / NSNotificationCenter.xm
Created July 10, 2015 00:30
Gives you a list of all NSNotifications
// TODO DEBUG DEVELOPMENT_ONLY REMOVE BEFORE LAUNCH
static NSMutableSet *mutableSet = nil;
%hook NSNotificationCenter
-(void)addObserver:(id)arg1 selector:(SEL)arg2 name:(id)name object:(id)arg4{
%orig;
if (mutableSet == nil) {
mutableSet = [[NSMutableSet alloc] init];
@kylehowells
kylehowells / cydia_report.py
Created July 30, 2015 00:13 — forked from conradev/cydia_report.py
Cydia Store Daily Report
#!/usr/bin/python
import string, time, calendar, hashlib, urllib2, smtplib
from email.mime.text import MIMEText
# Cydia globals
product_ids = ['org.thebigboss.somepackage', 'org.thebigboss.someotherpackage']
splits = [ 0.70, 0.35 ]
vendor_id = ""
vendor_secret = ""
@kylehowells
kylehowells / NSObject+MutableAssociatedDictionary.m
Last active March 25, 2016 16:55
A category on NSObject to allow you to add arbitrary objects to any object.
@import Foundation;
#import <objc/runtime.h>
@implementation NSObject (Helper)
-(NSMutableDictionary*)kh_associatedDictionary{
NSMutableDictionary *dictionary = objc_getAssociatedObject(self, @selector(associatedDictionary));
if (dictionary == nil) {
@synchronized(self) {
@kylehowells
kylehowells / download_apple_tv_videos.py
Last active November 24, 2017 17:47
Downloads every Apple TV screensaver video, with progress bar. Sorts them into appropriate folders, based on location. Names them based on the videos time of day.
import os
import sys
import json
import requests
from clint.textui import progress
def download_file(urlpath, filepath=None):
r = requests.get(urlpath, stream=True)
if filepath is None:
@kylehowells
kylehowells / download_apple_tv4k_videos.py
Created November 24, 2017 17:44
Downloads every Apple TV 4K screensaver video. Sorts them into appropriate folders, based on location. With download progress bar.
import os
import sys
import json
import requests
from clint.textui import progress
def download_file(urlpath, filepath=None):
r = requests.get(urlpath, stream=True)
@kylehowells
kylehowells / iOS App Distribution Methods.md
Last active February 26, 2019 20:18
The different ways to get an application installed on an iOS device (early 2019)

iOS App Distribution Methods

The different ways to get an application installed on an iOS device.

Background

iOS devices enforce code signing of all executable code run on the device. If the code in question is not signed by Apple's certificates then the OS will refuse to run the code. However, developers needs ways to run their code on real devices, without submitting to the AppStore each time. So there are a number of ways to get applications installed on iOS devices.

@kylehowells
kylehowells / BoxView.xaml
Created March 12, 2019 16:40
Xamarin Circular BoxView iOS Android Corner Radius
<BoxView BackgroundColor="Red"
CornerRadius="10"
RelativeLayout.WidthConstraint="20"
RelativeLayout.HeightConstraint="20">
<BoxView.CornerRadius>
<OnPlatform x:TypeArguments="CornerRadius">
<On Platform="iOS" Value="10" />
<On Platform="Android" Value="20" />
</OnPlatform>
</BoxView.CornerRadius>
@kylehowells
kylehowells / DebugFileAssociations.m
Created March 23, 2019 21:15
Print the preferred UTI Document Type for a file extension, then print all possible matching UTI's and their definitions to debug problems.
@import CoreServices;
// All Bundle Ids
NSString *pathExtension = @"db";
NSLog(@"pathExtension: %@", pathExtension);
CFStringRef preferedUTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)pathExtension, NULL);
NSLog(@"%@ - Preferred UTI: %@", pathExtension, preferedUTI);
CFDictionaryRef defintion = UTTypeCopyDeclaration(preferedUTI);
NSLog(@"defintion: %@", defintion);
@kylehowells
kylehowells / FileWatcher.cs
Created May 9, 2019 13:06
Monitor iOS files for changes using GCD dispatch_source_create DISPATCH_SOURCE_TYPE_VNODE in Xamarin
using System;
using ObjCRuntime;
using Foundation;
using CoreFoundation;
using System.IO;
namespace LoadRuntimeXAML.iOS
{
public class FileWatcher : IDisposable
{
@kylehowells
kylehowells / ast2text.py
Last active April 8, 2021 22:10
Extract the plain text from markdown, for plain text search.
import commonmark
with open('test.md', 'r') as myfile:
text = myfile.read()
parser = commonmark.Parser()
ast = parser.parse(text)
# Returns the text from markdown, stripped of the markdown syntax itself
def ast2text(astNode):