A parallax effect purely done in CSS, taken from: http://blog.keithclark.co.uk/pure-css-parallax-websites/
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
| String.prototype.trim = function() { | |
| return this.replace(/^\s+|\s+$/g, ""); | |
| }; |
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
| var timezoneAbbreviation = function(timezoneString) { | |
| var timezoneAbbreviations = { | |
| "Afghanistan Time": "AFT", | |
| "Alaska Daylight Time": "AKDT", | |
| "Alaska Standard Time": "AKST", | |
| "Amazon Summer Time": "AMST", | |
| "Amazon Time": "AMT", | |
| "Arabia Standard Time": "AST", | |
| "Argentina Time": "ART", | |
| "Armenia Summer Time": "AMST", |
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
| class String | |
| def filter_html_attribute(attribute_key, args={}) | |
| self.gsub!(/#{attribute_key}="([^"]*)"/) do |attribute| | |
| return "" if attribute.nil? | |
| attribute_value = $1.split(args[:split]).delete_if {|i| i.match(args[:match]) }.join(args[:join]) | |
| attribute_value += args[:append].to_s unless attribute_value.empty? | |
| attribute.replace("#{attribute_key}=\"#{attribute_value}\"") | |
| end | |
| self.gsub!(/ (#{attribute_key})=""/, "") | |
| end |
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
| class String | |
| def p(**args) | |
| gsub(/:[\w]*/){|match| args[match[1..-1].to_sym] || match} | |
| end | |
| end |
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
| <?php | |
| /** | |
| * Get array entries that match pattern in their keys. | |
| * | |
| * @link https://www.php.net/manual/en/function.preg-grep.php | |
| * @param string $pattern | |
| * @param array $assoc | |
| * @param int $flags 0 or PREG_GREP_INVERT | |
| * @return array | |
| */ |
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
| <?php | |
| function format_xml($xml, $formatOutput=TRUE, $declaration=TRUE) { | |
| $sxe = ($xml instanceof \SimpleXMLElement) ? $xml : simplexml_load_string($xml); | |
| $domElement = dom_import_simplexml($sxe); | |
| $domDocument = $domElement->ownerDocument; | |
| $domDocument->preserveWhiteSpace = false; | |
| $domDocument->formatOutput = (bool)$formatOutput; | |
| $domDocument->loadXML($sxe->asXML(), LIBXML_NOBLANKS); // Fixes newlines omitted by DomNode::appendChild() | |
| return (bool)$declaration ? $domDocument->saveXML() : $domDocument->saveXML($domDocument->documentElement); | |
| } |
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
| <?php | |
| function xml_to_json($xml, $formatted=TRUE) { | |
| $options = (bool)$formatted ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; | |
| return json_encode(simplexml_load_string($xml), $options); | |
| } |
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
| <?php | |
| // Invalid end tag </s> | |
| $html = <<<HTML | |
| <table> | |
| <tr> | |
| <td>123</s></td> | |
| <td>456</td> | |
| </tr> | |
| </table> | |
| HTML; |
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
| <?php | |
| function xml_to_array($xml) { | |
| return json_decode(str_replace(['{}', '"NULL"'], ['""', 'null'], json_encode(simplexml_load_string($xml))), TRUE); | |
| } |