// jQuery
$(document).ready(function() {
// code
})
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 | |
| /* | |
| * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
| * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
| * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
| * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
| * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
| * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
| * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
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 | |
| /* | |
| This function saved my life. | |
| found on: http://www.sitepoint.com/forums//showthread.php?t=438748 | |
| by: crvandyke | |
| It takes an object, and when all else if/else/recursive functions fail to convert the object into an associative array, this one goes for the kill. Who would'a thunk it?! | |
| */ | |
| $array = json_decode(json_encode($object), true); |
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
| function convertMS(ms) { | |
| var d, h, m, s; | |
| s = Math.floor(ms / 1000); | |
| m = Math.floor(s / 60); | |
| s = s % 60; | |
| h = Math.floor(m / 60); | |
| m = m % 60; | |
| d = Math.floor(h / 24); | |
| h = h % 24; | |
| return { d: d, h: h, m: m, s: s }; |
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
| CREATE TABLE IF NOT EXISTS `country` ( | |
| `id` int(11) NOT NULL AUTO_INCREMENT, | |
| `iso` char(2) NOT NULL, | |
| `name` varchar(80) NOT NULL, | |
| `nicename` varchar(80) NOT NULL, | |
| `iso3` char(3) DEFAULT NULL, | |
| `numcode` smallint(6) DEFAULT NULL, | |
| `phonecode` int(5) NOT NULL, | |
| PRIMARY KEY (`id`) | |
| ) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
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 | |
| /** | |
| * Merge two dimensional arrays my way | |
| * | |
| * Will merge keys even if they are of type int | |
| * | |
| * @param array $array1 Initial array to merge. | |
| * @param array ... Variable list of arrays to recursively merge. | |
| * |
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
| # This awk script splits an XML file and exports each node into separate file | |
| # It doesn't work if the main node has an attribute | |
| # It doesn't work if the main node contains a subnode with the same tagname, etc. | |
| # Use at your own risk, think before using. | |
| # Usage - replace "node" by your tag and run: $ awk -f split-xml.awk my.xml | |
| /<node>/ { | |
| rfile="node" count ".xml" | |
| print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > rfile | |
| print $0 > rfile | |
| getline |
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 parser = document.createElement('a'); | |
| parser.href = "http://example.com:3000/pathname/?search=test#hash"; | |
| parser.protocol; // => "http:" | |
| parser.hostname; // => "example.com" | |
| parser.port; // => "3000" | |
| parser.pathname; // => "/pathname/" | |
| parser.search; // => "?search=test" | |
| parser.hash; // => "#hash" | |
| parser.host; // => "example.com:3000" |
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
| //www.lsauer.com 2012 | |
| //Answer to: | |
| //http://stackoverflow.com/questions/881085/count-the-number-of-occurances-of-a-character-in-a-string-in-javascript/10671743#10671743 | |
| //There are at least four ways. The best option, which should also be the fastest -owing to the native RegEx engine -, is placed at the top. //jsperf.com is currently down, otherwise I would provide you with performance statistics. | |
| #1. | |
| ("this is foo bar".match(/o/g)||[]).length | |
| //>2 | |
| #2. | |
| "this is foo bar".split("o").length-1 |
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 | |
| add_filter( 'allowed_http_origins', 'my_add_origins' ); | |
| function my_add_origins( $origins ) { | |
| $origins[] = 'http://www.example.com'; // this will add www.example.com to the list of allowed origins when send_origin_headers() is called | |
| return $origins; | |
| } |
OlderNewer