This file contains hidden or 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
import 'dart:async'; | |
import 'package:firebase_database/firebase_database.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:shared_preferences/shared_preferences.dart'; | |
void main() { | |
runApp(new MyApp()); | |
} |
JavaScriptCore is a built-in iOS library that enables you to use JavaScript in apps alongside Objective-C and Swift. It lets developers read JavaScript from a string, execute it from Objective-C or Swift, and share data structures and functions across languages. We JavaScriptCore to share code between Web and iOS.
This file contains hidden or 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
// color - source color, which is must be replaced | |
// withColor - target color | |
// tolerance - value in range from 0 to 1 | |
func replaceColor(color:SKColor, withColor:SKColor, image:UIImage, tolerance:CGFloat) -> UIImage{ | |
// This function expects to get source color(color which is supposed to be replaced) | |
// and target color in RGBA color space, hence we expect to get 4 color components: r, g, b, a | |
assert(CGColorGetNumberOfComponents(color.CGColor) == 4 && CGColorGetNumberOfComponents(withColor.CGColor) == 4, | |
"Must be RGBA colorspace") |
- Code for generating the user_hash value for Intercom's Identity verfication (Note: Identity verification was prevoiusly called Secure Mode)
- Based on http://www.jokecamp.com/blog/examples-of-creating-base64-hashes-using-hmac-sha256-in-different-languages/#ruby
- When creating this for mobile, the final output needs to be in lowercase (the web version accepts both upper and lower case)
- So Javascript code below should only be used for testing unless modified and used to run on a server
This file contains hidden or 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
extension String { | |
func extractURLs() -> [NSURL] { | |
var urls : [NSURL] = [] | |
do { | |
let detector = try NSDataDetector(types: NSTextCheckingType.Link.rawValue) | |
detector.enumerateMatchesInString(self, | |
options: [], | |
range: NSMakeRange(0, text.characters.count), | |
usingBlock: { (result, _, _) in | |
if let match = result, url = match.URL { |