Skip to content

Instantly share code, notes, and snippets.

// https://stackoverflow.com/questions/32305891/index-of-a-substring-in-a-string-with-swift
extension StringProtocol where Index == String.Index {
func index(of string: Self, options: String.CompareOptions = []) -> Index? {
return range(of: string, options: options)?.lowerBound
}
func endIndex(of string: Self, options: String.CompareOptions = []) -> Index? {
return range(of: string, options: options)?.upperBound
}
func indexes(of string: Self, options: String.CompareOptions = []) -> [Index] {
var result: [Index] = []
@dnsmob
dnsmob / HideMobileAddressBar.js
Created October 7, 2015 14:14 — forked from danro/HideMobileAddressBar.js
Hide Browser Address Bar - Android + iPhone
function configAddressBar (addHeight) {
var defaultHeight = 50;
if (typeof addHeight == "undefined") addHeight = 1;
function hideAddressBar() {
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + defaultHeight + addHeight) + 'px';
}
@dnsmob
dnsmob / xcode custom shortcuts
Created June 19, 2015 15:34
xcode custom shortcuts
<key>Custom Keys</key>
<dict>
<key>Delete Line</key>
<string>moveToEndOfLine:, deleteToBeginningOfLine:, deleteToEndOfParagraph:</string>
<key>Duplicate Line Down</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
<key>Duplicate Line Up</key>
<string>selectLine:, copy:, moveToBeginningOfLine:, paste:, moveUp:, moveToBeginningOfLine:</string>
<key>Insert line above</key>
<string>moveToBeginningOfLine:, insertNewline:, moveUp:, moveToBeginningOfLine:</string>