Cross-browser function to trigger DOM events.
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($){ | |
//Finding min and max values in array from http://snippets.dzone.com/posts/show/769 | |
Array.prototype.min = function(){ return Math.min.apply({},this) }; | |
Array.prototype.max = function(){ return Math.max.apply({},this) }; | |
$.fn.masonry = function() { | |
this.each(function() { | |
var wall = $(this); |
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
<div class="input-text-wrap"> | |
<form action="http://www.google.com/search" method="get"> | |
<input class="text-input" type="text" name="q" autocomplete="off"/> | |
<span class="down-arrow"></span> | |
<input class="submit-button" type="submit" value="Search"/> | |
<ul> | |
<li>Wallpaper 3D</li> | |
<li>Anime</li> | |
<li>Manga</li> | |
<li>Comics List</li> |
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 setVisibleTimeout(callback, delay) { | |
var id = null, | |
t = 0, | |
prefix = ''; | |
'o webkit moz ms'.replace(/\S+/g, function(p) { | |
if ((p + 'Hidden') in document) { | |
prefix = p; | |
} | |
}); | |
function onVisibilityChange(event) { |
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 | |
/*! Based on <https://github.com/mecha-cms/cms/blob/master/system/kernel/converter.php> */ | |
function extract_html_attributes($input) { | |
if( ! preg_match('#^(<)([a-z0-9\-._:]+)((\s)+(.*?))?((>)([\s\S]*?)((<)\/\2(>))|(\s)*\/?(>))$#im', $input, $matches)) return false; | |
$matches[5] = preg_replace('#(^|(\s)+)([a-z0-9\-]+)(=)(")(")#i', '$1$2$3$4$5<attr:value>$6', $matches[5]); | |
$results = array( | |
'element' => $matches[2], | |
'attributes' => null, | |
'content' => isset($matches[8]) && $matches[9] == '</' . $matches[2] . '>' ? $matches[8] : null |
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() { | |
// Key maps for the deprecated `KeyboardEvent.keyCode` | |
var keys = { | |
// control | |
8: 'backspace', | |
9: 'tab', | |
13: 'enter', | |
16: 'shift', | |
17: 'control', |
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
// see blog post: http://www.hiddentao.com/archives/2013/07/08/generate-overridable-getters-and-setters-in-javascript/ | |
Function.prototype.generateProperty = function(name, options) { | |
// internal member variable name | |
var privateName = '__' + name; | |
options = options || {}; | |
options.get = ('undefined' === typeof options.get ? true : options.get ); | |
options.set = ('undefined' === typeof options.set ? true : options.set ); | |
// pre-initialise the internal variable? |
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 do_slug($text, $lower = true, $strip_underscores_and_dots = true, $connector = '-') { | |
$text_accents = array( | |
// Numeric characters | |
'¹' => 1, | |
'²' => 2, | |
'³' => 3, | |
// Latin | |
'°' => 0, |
foobar, foo, bar, baz, qux, quux, corge, grault, garply, waldo, fred, plugh, xyzzy, thud
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
// Reply for <https://medium.com/@Dewey92/cleaner-code-dengan-function-composition-137f30d928e4> | |
function compose() { | |
var i, arg = arguments, | |
output = arg.pop(); | |
for (i = 0; i < arg.length; ++i) { | |
if (typeof arg[i] !== "function") continue; | |
output = arg[i](output); | |
} | |
return output; |