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
import { useState, useEffect, useCallback } from 'react'; | |
export const useVisbilityState = () => { | |
const [visibilityState, setVisibilityState] = useState(null); | |
const handleVisbilityChange = useCallback(() => { | |
setVisibilityState(document.visibilityState); | |
}, [setVisibilityState]); | |
useEffect(() => { |
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
git config --global core.excludesfile ~/.gitignore | |
echo ".DS_Store" >> ~/.gitignore | |
echo "node_modules/" >> ~/.gitignore | |
echo "npm-debug.log" >> ~/.gitignore | |
echo ".sass-cache/" >> ~/.gitignore | |
echo "*.sublime-workspace" >> ~/.gitignore |
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
// Implementation for tracking the vertical scroll of a page and firing events at 25%, 50%, 75%, 100% positions | |
// Requires jQuery (feel free to fork a version that doesn't!) | |
var scrollPercentages = { | |
scroll25: false, | |
scroll50: false, | |
scroll75: false, | |
scroll100: false | |
} |
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
// Name of storyboard, without the .storyboard extension | |
var storyboard = UIStoryboard(name: "Main", bundle: nil) | |
// The type is the view controller class name, in this case 'ViewControllerLaunch' | |
// You need to make sure the view controller in storyboard has an identifier set | |
// The identifier in this example is 'Launch' | |
var viewController: ViewControllerLaunch = storyboard.instantiateViewControllerWithIdentifier("Launch") as ViewControllerLaunch | |
// Show this view controller | |
window?.rootViewController = viewController |
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 hexStringToUIColor (hex:String) -> UIColor { | |
var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet() as NSCharacterSet).uppercaseString | |
if (cString.hasPrefix("#")) { | |
cString = cString.substringFromIndex(advance(cString.startIndex, 1)) | |
} | |
if (countElements(cString) != 6) { | |
return UIColor.grayColor() | |
} |