Skip to content

Instantly share code, notes, and snippets.

View ieliwb's full-sized avatar
🌴
On vacation

ieliwb

🌴
On vacation
View GitHub Profile
@zats
zats / README.md
Last active July 2, 2019 10:45
UIPreviewActionItem for SFSafariViewController through delegation not subclassing

Adding UIPreviewActionItem to SFSafariViewController might be a tedious task. This extansion should help.

let vc = SFSafariViewController(initialURL: url, entersReaderIfAvailable: true)
vc.previewActionItemsDelegate = self

When presenting SFSafariViewController use convenience initializer that will store original URL for later, it'll make custom action requiring original URL easier. But it's not mandatory.

Here is the delegate implementation, this is where we might want to use initialURL

func safariViewControllerPreviewActionItems(controller: SFSafariViewController) -> [UIPreviewActionItem] {
@dmitriynet
dmitriynet / php
Created November 20, 2015 10:05
mb_unserialize
function mb_unserialize($string)
{
$recovered = preg_replace_callback(
'!(?<=^|;)s:(\d+)(?=:"(.*?)";(?:}|a:|s:|b:|d:|i:|o:|N;))!s',
function($match) {
return 's:' . mb_strlen($match[2], '8bit');
},
$string
);
@jerrybendy
jerrybendy / filter_relative_url.php
Last active July 6, 2018 10:18
PHP转换网址相对路径到绝对路径的一种方法 https://icewing.cc/php-conv-addr-re-ab-2.html
/**
* 把从HTML源码中获取的相对路径转换成绝对路径
* @param string $url HTML中获取的网址
* @param string $URI 用来参考判断的原始地址
* @return 返回修改过的网址,如果网址有误则返回FALSE
*/
function filter_relative_url($url, $URI){
//STEP1: 先去判断URL中是否包含协议,如果包含说明是绝对地址则可以原样返回
if(strpos($url, '://') !== FALSE){
return $url;
BOOL isCurrentlyDaytime(CGFloat latitude, CGFloat longitude)
{
// http://users.electromagnetic.net/bu/astro/iyf-calc.php
// http://aa.quae.nl/en/reken/zonpositie.html
static NSUInteger const secondsPerDay = 60*60*24;
static NSTimeInterval const julianLeap = 0.0009;
static double const degreeToRadian = M_PI/180.0;
static double const radianToDegree = 180.0/M_PI;
@linw1995
linw1995 / Packaging fonts in configuration profiles for installing on iOS.py
Created June 16, 2017 12:29
Packaging fonts in configuration profiles for installing on iOS
# coding: utf-8
import re
import hashlib
import sys
from base64 import b64encode
from random import choice
items = ['8', '9', 'a', 'b']
names = sys.argv
@ufologist
ufologist / ios-body-click-bubble-bug.html
Created September 19, 2017 09:06
iOS body click 事件冒泡的 bug
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>iOS body click 事件冒泡的 bug</title>
</head>
<body>
<h1>点击 h1 不会冒泡到 body</h1>
@rproenca
rproenca / Clipboard.js
Last active May 28, 2024 08:57
Copy text to clipboard using Javascript. It works on Safari (iOS) and other browsers.
window.Clipboard = (function(window, document, navigator) {
var textArea,
copy;
function isOS() {
return navigator.userAgent.match(/ipad|iphone/i);
}
function createTextArea(text) {
textArea = document.createElement('textArea');
//
// PHPhotoLibrary+CustomPhotoAlbum.h
// dashcam_ios
//
// Created by hc on 2016/11/25.
// Copyright © 2016年 Sunvalley. All rights reserved.
//
#import <Photos/Photos.h>
###### CONSISTENCY BETWEEN MACOS AND IOS #####
#
# In order to use the same PodFile with MacOS, we need to unlink the libraries that do not support Catalyst, filter
# files in native targets build phases, filter dependencies and make sure the unsupported frameworks along with their
# their bundle resources are not included in the final archive. For that, we use `platform_filter` to specify 'ios' and
# 'OTHER_LDFLAGS[sdk=iphone*]' to link those libraries for iPhone and iPad. Besides, we modify "*frameworks.sh" and
# "*resrouces.sh" to skip installation for architecture x86_64.
#
# *Notice*: 'sdk=iphone*' excludes macOS, even though Catalyst is compiled with iOS SDK.
#
@rikumi
rikumi / iconsur.sh
Last active October 24, 2023 06:46
My personal iconsur setup
# See https://github.com/rikumi/iconsur
yarn global add iconsur
sudo iconsur set /Applications/Android\ File\ Transfer.app -k Airdroid
sudo iconsur set /Applications/Android\ Studio.app/ -l -c 7a5 -s 0.8
sudo iconsur set /Applications/DaisyDisk.app/ -l
sudo iconsur set /Applications/Decompressor.app/ -l
sudo iconsur set /Applications/Discord.app/
sudo iconsur set /Applications/Google\ Chrome.app/
sudo iconsur set /Applications/IINA.app/ -l -c 161d22