Skip to content

Instantly share code, notes, and snippets.

@activcoding
activcoding / FuzzySearch.swift
Created February 6, 2024 17:40
This Fuzzy Search algorithm offers both speed and ease of understanding. A significant advantage is its capability to not only provide the score but also the range of matching characters.
import Foundation
/// FuzzySearchCharacters is used to normalise strings
struct FuzzySearchCharacter {
let content: String
// normalised content is referring to a string that is case- and accent-insensitive
let normalisedContent: String
}
/// FuzzySearchString is just made up by multiple characters, similar to a string, but also with normalised characters
@scriptingosx
scriptingosx / Build Package and Notarize
Last active June 12, 2024 14:23
Use this as a Archive Post-action in Xcode for command line tool projects. More details in this post: https://scriptingosx.com/?p=1588
# Developer ID Installer cert name
sign_cert="Developer ID Installer: Name (ABCD123456)"
# profile name used with `notarytool --store-credentials`
credential_profile="notary-example.com"
# data from build settings
pkg_name="$PRODUCT_NAME"
identifier="$PRODUCT_BUNDLE_IDENTIFIER"
version="$MARKETING_VERSION"
@Geekfish
Geekfish / merge_pdfs.py
Created January 31, 2017 16:07
pyPDF2 merge 2 pdf pages into one
from PyPDF2 import PdfFileReader, PdfFileWriter
from PyPDF2.pdf import PageObject
reader = PdfFileReader(open("invoice.pdf",'rb'))
invoice_page = reader.getPage(0)
sup_reader = PdfFileReader(open("supplement.pdf",'rb'))
sup_page = sup_reader.getPage(1) # We pick the second page here
translated_page = PageObject.createBlankPage(None, sup_page.mediaBox.getWidth(), sup_page.mediaBox.getHeight())
@alexrepty
alexrepty / mac_apps.md
Created November 16, 2016 11:43
Some beautifully designed and crafted macOS apps in 2016
@willthink
willthink / contact.m
Last active March 6, 2023 20:05
Using CNContactStore in Objective C to query contacts info
#import <Contacts/Contacts.h>
@implementation ContactsScan
- (void) contactScan
{
if ([CNContactStore class]) {
//ios9 or later
CNEntityType entityType = CNEntityTypeContacts;
if( [CNContactStore authorizationStatusForEntityType:entityType] == CNAuthorizationStatusNotDetermined)
@dtrotzjr
dtrotzjr / openssl-maker.sh
Last active September 27, 2016 21:35 — forked from letiemble/openssl-maker.sh
A bash script to generate "all-in-one" OpenSSL static libraries for OS X and iOS. The script produces fat static libraries (i386,x86_64 for OS X) and (i386,armv7,armv7s,arm64 for iOS) suitable for integration in both OS X and iOS project.
#!/bin/bash
###############################################################################
## ##
## Build and package OpenSSL static libraries for OSX/iOS ##
## ##
## This script is in the public domain. ##
## Creator : Laurent Etiemble ##
## ##
###############################################################################
@jspahrsummers
jspahrsummers / GHRunLoopWatchdog.h
Created January 28, 2015 20:50
A class for logging excessive blocking on the main thread
/// Observes a run loop to detect any stalling or blocking that occurs.
///
/// This class is thread-safe.
@interface GHRunLoopWatchdog : NSObject
/// Initializes the receiver to watch the specified run loop, using a default
/// stalling threshold.
- (id)initWithRunLoop:(CFRunLoopRef)runLoop;
/// Initializes the receiver to detect when the specified run loop blocks for
@mlapointe
mlapointe / KeychainHelper.h
Last active May 29, 2024 18:33
KeychainHelper - Simple Keychain access for iOS Keychain Services
//
// KeychainHelper.h
#import <Foundation/Foundation.h>
@interface KeychainHelper : NSObject
@property (strong, nonatomic) NSMutableDictionary * keychainItem;
@letiemble
letiemble / openssl-maker.sh
Last active April 23, 2023 11:33
A bash script to generate "all-in-one" OpenSSL static libraries for OS X and iOS. The script produces fat static libraries (i386, x86_64 for OS X) and (i386, x86_64, armv7, armv7s, arm64 for iOS) suitable for integration in both OS X and iOS project.
#!/bin/bash
###############################################################################
## ##
## Build and package OpenSSL static libraries for OSX/iOS ##
## ##
## This script is in the public domain. ##
## Creator : Laurent Etiemble ##
## ##
###############################################################################
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):