Skip to content

Instantly share code, notes, and snippets.

View scheinem's full-sized avatar

Manfred Scheiner scheinem

View GitHub Profile
@scheinem
scheinem / gravatars-from-mac-os.sh
Last active March 30, 2018 12:00
This BASH script downloads all gravatars which are available for the mail adresses stored in the macOS contacts application.
#!/bin/bash
OLD_IFS=$IFS
IFS=$'\n'
databases=( $(find ~/Library/Application\ Support/AddressBook -name "*.abcddb") )
for database in ${databases[*]}
do
echo "Database: $database"
mailAddressesString=$(sqlite3 $database "SELECT ZADDRESS FROM ZABCDEMAILADDRESS;")
@scheinem
scheinem / STEPS_TO_RESIGN_IPA.txt
Last active April 16, 2017 14:54
Re-Sign .ipa file with certificate from same or different Apple Developer Account
1. Unzip <File>.ipa
2. cd into the <File>.app inside the unzipped .ipa (= Payload Folder)
3. /usr/bin/security cms -D -i embedded.mobileprovision > ../Entitlements.plist (= Place the Entitlements next to <File>.app)
4. Remove outer dict only leaving inner dict „Entitlements“ in Entitlements.plist (also remove the "<key>Entitlements</key>")
5. Delete Folder "_CodeSignature" in <File>.app, in contained "Framework" folder and all .framework folders
6. Delete all .mobileprovision files in <File>.app, in contained "Framework" folder and all .framework folders
7. Add your <New>.mobileprovision as embedded.mobileprovision to <File>.app/
8. cd to location where Entitlements.plist and <File>.app are located
9. For each .framework and each .dylib: codesign -f -v -s "<Certificate Name>" --entitlements Entitlements.plist <fremworkOrDylibFile>
10. codesign -f -v -s "<Certificate Name>" --entitlements Entitlements.plist <File>.app
@scheinem
scheinem / countElementsBugMaybe.swift
Last active August 29, 2015 14:10
countElements() bug in Swift?!
/**
* Is this a bug or is this the way as it is designed by Apple?
* I can't think that this isn't a bug but who knows...
*/
var str = "\r\n"
countElements(str) // Returns 1
(str as NSString).length // Returns 2

Keybase proof

I hereby claim:

  • I am scheinem on github.
  • I am scheinem (https://keybase.io/scheinem) on keybase.
  • I have a public key whose fingerprint is F195 B2DD EF89 2479 C2F1 473E B9D6 5529 C29B 0F43

To claim this, I am signing this object:

@scheinem
scheinem / CodeForUIToolbarBugiOS8Beta5.m
Last active August 29, 2015 14:05
UIToolbar Bug iOS8 Beta 5 AND GM - UPDATE: Fix included!
// Execute the following code somewhere in your app
UIToolbar *datePickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.f, 50.f, self.window.bounds.size.width, 44.f)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStylePlain target:self action:nil];
UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithTitle:@"OK" style:UIBarButtonItemStyleDone target:self action:nil];
datePickerToolbar.items = @[cancelButton, flexibleSpace, doneButton];
@scheinem
scheinem / tableViewEditActions.m
Last active September 26, 2019 05:23
iOS 8 beta 2: ''tableView:editActionsForRowAtIndexPath:"
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"More" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// show UIActionSheet
}];
moreAction.backgroundColor = [UIColor greenColor];
UITableViewRowAction *flagAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"Flag" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {
// flag the row
}];
@scheinem
scheinem / Weird UIDatePicker bug
Last active August 29, 2015 13:55
Weird UIDatePicker setFrame: bug
// First run:
CGRect testRect = CGRectMake(0.f, 0.f, 320.f, 215.5f);
testRect = CGRectIntegral(CGRectInset(testRect, 15.f, 0.f));
// RESULT: testRect = (15 0; 290 216);
self.datePicker.frame = testRect;
// RESULT: self.datePicker.frame = (15 0; 290 216);
// Second run:
@scheinem
scheinem / iOS TouchID API approach
Created September 16, 2013 09:13
iOS TouchID API approach
if ([[UIDevice currentDevice] supportsTouchID]) {
[[UIDevice currentDevice] authenticateUsingTouchIDWithMessage:@"Authenticate to allow 'Hello World' to use the password you've entered at first launch" completionHandler:^(BOOL success){}];
}
/**
* Detects paragraphs in an UITextView and stores it in an NSMutableArray called "paragraphs"
*
* Author: Manfred Scheiner (@scheinem)
* Created on 03.07.2013
*/
- (void)textViewDidChange:(UITextView *)textView; {
NSMutableArray *paragraphs = [NSMutableArray array];
for (NSString *component in [textView.text componentsSeparatedByString:@"\n"]) {