Skip to content

Instantly share code, notes, and snippets.

@irace
irace / gist:535c9aa3314ee41fb902
Last active April 19, 2018 01:26
Activity items and share extensions

I'm not 100% sure this is all accurate but:

It seems as though share extension predicates are a lot more specific than we originally thought. For example, if Instapaper declares support for only NSExtensionActivationSupportsWebURLWithMaxCount = 1, this means that activity controllers configured with a URL but also some other item types too, e.g. a string, won't show Instapaper.

So basically if you have multiple items in your activity items array, your controller will only show extensions that support all types. I imagine this would be extremely limiting, and as such, think the best option is to:

  • Only include a single provider in your items array. The provider would have a placeholder of a single type that will be provided to any activity or extension that isn't specifically accounted for
  • In the provider, specifically hardcode alternative item types for activities that need an alternative to the placeholder type:
    • "Copy" activity could use photo data, if present
  • "Mail" activity woul
@alexchung
alexchung / Blockout.php
Created February 9, 2014 23:10
Blockout encryption/decryption methods in PHP
<?php
class Blockout {
public static function enblockout($s, $key) {
// user provided blockout encoder
return;
}
public static function deblockout($blockout, $key) {
@isutton
isutton / MyWindow.h
Created October 25, 2012 09:21
UIWindow subclass that adds rounded top corners.
@interface MyWindow : UIWindow
@end
@dzuelke
dzuelke / bcrypt.php
Last active March 28, 2023 13:15
How to use bcrypt in PHP to safely store passwords (PHP 5.3+ only)
<?php
// secure hashing of passwords using bcrypt, needs PHP 5.3+
// see http://codahale.com/how-to-safely-store-a-password/
// salt for bcrypt needs to be 22 base64 characters (but just [./0-9A-Za-z]), see http://php.net/crypt
$salt = substr(strtr(base64_encode(openssl_random_pseudo_bytes(22)), '+', '.'), 0, 22);
// 2y is the bcrypt algorithm selector, see http://php.net/crypt
// 12 is the workload factor (around 300ms on my Core i7 machine), see http://php.net/crypt