A parallax effect purely done in CSS, taken from: http://blog.keithclark.co.uk/pure-css-parallax-websites/
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
// Usage: "abc{def}ghi".p({def:"xyz"}); => "abcxyzghi" | |
String.prototype.p = function(obj) { | |
return this.replace(/\{[^\}]+\}/g, function(key) { | |
return obj[key.replace(/^\{([^\}]+)\}$/, "$1")] || key; | |
}); | |
}; |
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
window.location.href returns the URL of the current page | |
http://www.example.org:8888/foo/bar/index.html?q=baz&w=io#bang | |
window.location.origin returns the protocol, hostname and port number of a URL | |
http://www.example.org:8888 | |
window.location.protocol returns the web protocol used (http:// or https://) | |
http: | |
window.location.hostname returns the domain name of the web host |
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
String.prototype.trim = function() { | |
return this.replace(/^\s+|\s+$/g, ""); | |
}; |
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
def is_blank(value): | |
return False if value is not False and value in [0, 0.0] else not value |
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 hsc($value, $args=NULL) { | |
$default_args = array('flags'=>ENT_COMPAT, 'encoding'=>'UTF-8', 'double_encode'=>FALSE); | |
extract(array_merge($default_args, (array)$args)); | |
return htmlspecialchars((string)$value, (int)$flags, (string)$encoding, (bool)$double_encode); | |
} |
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
def blank? | |
self.respond_to?(:empty?) ? self.empty? : !self | |
end |
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 | |
// Invalid end tag </s> | |
$html = <<<HTML | |
<table> | |
<tr> | |
<td>123</s></td> | |
<td>456</td> | |
</tr> | |
</table> | |
HTML; |
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 xml_to_array($xml) { | |
return json_decode(str_replace('{}', '""', json_encode(simplexml_load_string($xml))), TRUE); | |
} |
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 xsd_to_json($xsd_file, $formatted = 448) { | |
$xml_file = preg_replace('/\.xsd$/', '.xml', $xsd_file); | |
$json_file = preg_replace('/\.xsd$/', '.json', $xsd_file); | |
$doc = new DOMDocument(); | |
$doc->preserveWhiteSpace = true; | |
$doc->load($xsd_file); | |
$doc->save($xml_file); | |
$xml = file_get_contents($xml_file); | |
$obj = str_replace($doc->lastChild->prefix.':', "", $xml); |
OlderNewer