View Utils.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool { | |
switch navigationType { | |
case .linkClicked: | |
// Open links in Safari | |
guard let url = request.url else { return true } | |
if #available(iOS 10.0, *) { | |
UIApplication.shared.open(url, options: [:], completionHandler: nil) | |
} else { | |
// openURL(_:) is deprecated in iOS 10+. |
View get_random_elements.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_random_elements($array, $limit = 0 ) { | |
shuffle($array); | |
if ( $limit > 0 ) { | |
$array = array_splice($array, 0, $limit); | |
} | |
return $array; | |
} | |
?> |
View replace_all.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function escapeRegExp(str) { | |
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"); | |
} | |
function replaceAll(str, find, replace) { | |
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace); | |
} |