Skip to content

Instantly share code, notes, and snippets.

@pepasflo
pepasflo / .gitignore
Last active October 22, 2023 12:06
Scripts for encrypting / decrypting secrets (to prevent them from being accidentally checked into git)
secrets/
#!/bin/bash
# This script checks the binary and all nested frameworks for duplicated classes (both ObjectiveC and Swift).
# The script fails if it finds any duplicated classes.
function print_classes() {
otool -ov "$1" |
sed -n '/Contents of (__DATA,__objc_classlist)/,/Contents of/p' | # all lines for (__DATA,__objc_classlist) section
egrep '^[0-9]' | # take just a class header
cut -d ' ' -f 3 | # take just a symbol name
#!/bin/bash
source_framework_path="$1"
target_bundle_dir="$2"
framework_name="$(basename "${source_framework_path}")"
module_name="$(basename -s .framework "${framework_name}")"
bundle_name="${module_name}.bundle"
target_bundle_path="${target_bundle_dir}/${bundle_name}"
print_usage() {
import Foundation
public extension Bundle {
private final class Marker {}
// Looking for bundle involves a lot of IO
private static let cache: NSCache<NSString, Bundle> = NSCache<NSString, Bundle>()
public static func resourcesBundle(forModuleName moduleName: String) -> Bundle {
@Nirma
Nirma / FTPUpload.swift
Last active December 30, 2023 02:11
Upload a file via FTP on iOS or macOS
import Foundation
import CFNetwork
public class FTPUpload {
fileprivate let ftpBaseUrl: String
fileprivate let directoryPath: String
fileprivate let username: String
fileprivate let password: String
@AmitaiB
AmitaiB / SwiftXOR.swift
Created November 17, 2016 04:41
Swift 3 Logical XOR Operator
precedencegroup BooleanPrecedence { associativity: left }
infix operator ^^ : BooleanPrecedence
/**
Swift Logical XOR operator
```
true ^^ true // false
true ^^ false // true
false ^^ true // true
false ^^ false // false
```
@TheAdamBorek
TheAdamBorek / pre_push.md
Last active June 1, 2016 17:40
pre_push git hook which invokes synx script before every push

Instalation

To install this hook you have to create a pre_push file inside .git/hooks/ and paste there the script written below. Next you have to set execute permisions with following command:

$ chmod a+x pre_push

Don't forget to change the project name inside the script.

@bmatcuk
bmatcuk / symbolizing_osx_crash_logs.md
Created May 29, 2014 21:43
How to symbolize OSX crash logs

How to Symbolize OSX Crash Logs

Unfortunately, xcode does not yet have support for importing OSX crash logs and symbolizing them. Therefore, you must use the command line and a little bit of manual work.

  1. Find your dSYM file.
    1. Assuming you are using xcode's archive functionality, open the Organizer window from the Window menu.
    2. Click the Archives tab.
    3. Right click on the appropriate build and select Show in Finder.
    4. When Finder opens, right click on the selected archive and select Show Package Contents.
    5. Navigate to the dSYM directory and copy the appropriate dSYM file to a temporary directory.
  2. Then navigate to Products, then Applications, and copy the app file to the same temporary directory.
@ericallam
ericallam / AppDelegate.m
Created May 22, 2014 14:49
Interactive Animated Transition Example
//
// AppDelegate.m
// AnimationExamplesiPhone
//
// Created by Eric Allam on 10/05/2014.
#import "AppDelegate.h"
#pragma mark - UIColor Additions
@robmooney
robmooney / gist:923301
Created April 16, 2011 17:07
Get the MKCoordinateRegion that encompasses a set of MKAnnotations
// returns a MKCoordinateRegion that encompasses an array of MKAnnotations
- (MKCoordinateRegion)regionForAnnotations:(NSArray *)annotations {
CLLocationDegrees minLat = 90.0;
CLLocationDegrees maxLat = -90.0;
CLLocationDegrees minLon = 180.0;
CLLocationDegrees maxLon = -180.0;
for (id <MKAnnotation> annotation in annotations) {