Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.
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
exports.ext = function () { | |
var extTypes = { | |
"3gp" : "video/3gpp" | |
, "a" : "application/octet-stream" | |
, "ai" : "application/postscript" | |
, "aif" : "audio/x-aiff" | |
, "aiff" : "audio/x-aiff" | |
, "asc" : "application/pgp-signature" | |
, "asf" : "video/x-ms-asf" | |
, "asm" : "text/x-asm" |
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
// class manipulation from http://www.openjs.com/scripts/dom/class_manipulation.php | |
function hasClass(ele,cls) { | |
return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); | |
} | |
function addClass(ele,cls) { | |
if (!this.hasClass(ele,cls)) ele.className += " "+cls; | |
} | |
function removeClass(ele,cls) { |
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
- (UIViewController *)topViewController{ | |
return [self topViewController:[UIApplication sharedApplication].keyWindow.rootViewController]; | |
} | |
- (UIViewController *)topViewController:(UIViewController *)rootViewController | |
{ | |
if (rootViewController.presentedViewController == nil) { | |
return rootViewController; | |
} | |
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
/** | |
* Get parent node for given tagname | |
* @param {Object} node DOM node | |
* @param {String} tagname HTML tagName | |
* @return {Object} Parent node | |
*/ | |
function getParentByTagName(node, tagname) { | |
var parent; | |
if (node === null || tagname === '') return; | |
parent = node.parentNode; |
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
// easing functions http://goo.gl/5HLl8 | |
Math.easeInOutQuad = function (t, b, c, d) { | |
t /= d/2; | |
if (t < 1) { | |
return c/2*t*t + b | |
} | |
t--; | |
return -c/2 * (t*(t-2) - 1) + b; | |
}; |
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 | |
require_once("/path/to/vendor/mixpanel/mixpanel-php/lib/Mixpanel.php"); // import the Mixpanel class | |
// get the Mixpanel singelton (will be created if it doesn't exist) | |
$mp = Mixpanel::getInstance("MIXPANEL_PROJECT_TOKEN"); | |
// this would likely come from a database or session variable | |
$user_id = 12345; |
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 filesize_formatted($path) | |
{ | |
$size = filesize($path); | |
$units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); | |
$power = $size > 0 ? floor(log($size, 1024)) : 0; | |
return number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power]; | |
} |
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
1033edge.com | |
11mail.com | |
123.com | |
123box.net | |
123india.com | |
123mail.cl | |
123qwe.co.uk | |
126.com | |
150ml.com | |
15meg4free.com |
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
// The image is originally animated on to the view controller then added to the scroll view. | |
// So, there might be some animation residue in here. | |
// Class needs: <UIScrollViewDelegate> | |
func viewDidLoad() { | |
let width = UIScreen.mainScreen().bounds.size.width | |
let aspect: CGFloat = width / shotWidth | |
var frame = CGRectMake(0, 0, shotWidth * aspect, shotHeight * aspect) | |
self.scrollView = UIScrollView(frame: frame) |
OlderNewer