Skip to content

Instantly share code, notes, and snippets.

anonymous
anonymous / blockerList.json
Created June 25, 2015 00:05
Testing Safari Content Blocker on iMore.com
[
{
"action": {
"type": "block"
},
"trigger": {
"url-filter": ".*",
"resource-type": ["script"],
"load-type": ["third-party"],
"if-domain": ["imore.com"]
@steipete
steipete / gist:99f8aa8d6527fa027fd6
Last active August 29, 2015 14:25
Mirror for https://forums.developer.apple.com/thread/11098 since that needs moderation first (submitted Jul 16 2015)
We're working on supporting Bitcode in PSPDFKit but hit a blocking issue with OpenSSL (latest 1.0.2d).
We're using a script that downloads and builds OpenSSL into fat static libraries for both Mac and iOS. I've put the gist here:
https://gist.github.com/steipete/ce09ba176a4b8ef66b2d/bf053eab1c0f8494dcd3748079543c4ed4367b9c
Enabling Bitcode should be as easy as adding `-fembed-bitcode` as clang flag according to this entry. That's exactly what I did.
Now things build, but the script eventually stops with this error:
ld: could not open bitcode temp file: ../libcrypto.a(aes-x86_64.o) for architecture x86_64
@jefflarkin
jefflarkin / gpio.sh
Last active April 13, 2018 22:15
BASH functions for using the C.H.I.P. GPIO pins.
#!/bin/bash
#FIXME Add usage() function to improve documentation
# Enable exposure of the specified GPIO pin (0-8)
gpio_enable()
{
if [[("$1" -lt 0) || ("$1" -gt 8)]] ; then
echo "Valid pins are 0-8"
return -1;
fi
@joech4n
joech4n / s3DuByPrefix.sh
Last active November 28, 2018 16:40
Get bucket size and object count by first level prefix (i.e. bucket/prefix1, bucket/prefix2)
#!/bin/sh
BUCKETNAME=mybucketname; REGION=us-east-1; for prefix in $(aws s3api list-objects --bucket $BUCKETNAME --delimiter '/' --output text --region $REGION |grep COMMONPREFIX |tail -n+2| awk '{print $2}'); do echo "Totals for $prefix"; aws s3 ls --summarize --human-readable --recursive s3://$BUCKETNAME/$prefix --region $REGION ; done |grep Total
@heiberg
heiberg / README.md
Last active June 9, 2018 18:45
YapDatabaseExtensions and CloudKit

YapDatabaseExtensions and CloudKit

This is a follow-up to this question, seeking advice on how to use YapDatabaseExtensions' value types with the CloudKit extension for YapDatabase.

Dan Thorpe offered some excellent suggestions in the discussion linked above. Many thanks to him. This is my first stab at a solution. I hope I didn't butcher his advice too badly.

Intention

If this is useful to anyone trying to add CloudKit sync to an app using YapDatabaseExtensions and ValueCoding that's terrific.

$ git clone -b 1.22 https://github.com/crosstool-ng/crosstool-ng.git
$ cd crosstool-ng
$ ./bootstrap
$ ./configure --prefix=/usr/local
$ make
$ sudo make install
$ cd ..
$ mkdir ctng
$ cd rpi1
$ ct-ng menuconfig
@steipete
steipete / ios-xcode-device-support.sh
Last active December 12, 2023 03:36
Using iOS 15 devices with Xcode 12.5 (instead of Xcode 13)
# The trick is to link the DeviceSupport folder from the beta to the stable version.
# sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :)
# Support iOS 15 devices (Xcode 13.0) with Xcode 12.5:
sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport
# Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions
# (A similar approach works for older versions too, just change the version number after DeviceSupport)
@ageis
ageis / systemd_service_hardening.md
Last active April 19, 2024 23:47
Options for hardening systemd service units

security and hardening options for systemd service units

A common and reliable pattern in service unit files is thus:

NoNewPrivileges=yes
PrivateTmp=yes
PrivateDevices=yes
DevicePolicy=closed
ProtectSystem=strict
@steipete
steipete / PSPDFGenerics.h
Last active April 28, 2020 15:08
Override copy and mutableCopy on Objective-C collection classes to pass along both the collection type and the generic info. This is a header-only "library". MIT licensed. Craving for more? foreach: https://gist.github.com/steipete/7e3c69b985165dc23c5ec169b857ff42 even more: https://pspdfkit.com/blog/2016/swifty-objective-c/ - ships in https://p…
//
// PSPDFGenerics.h
// PSPDFFoundation
//
// PSPDFKit is the leading cross-platform solution for integrating PDFs into your apps: https://pspdfkit.com.
// Try it today using our free PDF Viewer app: https://pdfviewer.io/
//
// This file is MIT licensed.
/**
@smileyborg
smileyborg / SelfSizingTableHeaderAndTableFooterViews.swift
Last active February 9, 2024 09:53
How to manually self-size UITableView tableHeaderView/tableFooterView in iOS 11
// For the best results, your tableHeaderView/tableFooterView should be a UITableViewHeaderFooterView with your content inside the contentView.
let tableHeaderView = UITableViewHeaderFooterView()
let fittingSize = CGSize(width: tableView.bounds.width - (tableView.safeAreaInsets.left + tableView.safeAreaInsets.right), height: 0)
let size = tableHeaderView.systemLayoutSizeFitting(fittingSize, withHorizontalFittingPriority: .required, verticalFittingPriority: .fittingSizeLevel)
tableHeaderView.frame = CGRect(origin: .zero, size: size)
tableView.tableHeaderView = tableHeaderView
// When you set this view to the tableHeaderView/tableFooterView on the table view, the table view will preserve the existing size of its frame.
// If you need to change the size, remove the tableHeaderView/tableFooterView, set a new frame on it, then re-set it on the table view again.