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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
// ------------------------------------ |
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
$("#foo").click(function(e){ | |
if (e.clientX) { | |
// native mouse click | |
} | |
else { | |
// triggered mouse click | |
} | |
}); |
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
for (var i = 0, j = foo.length; i < j; i++) { | |
// do stuff | |
} | |
for (var i = foo.length; i;) { | |
// first usage in loop: blah[--i] | |
// do stuff slightly faster in reverse order | |
} |
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
// HOWTO: load LABjs itself dynamically! | |
// inline this code in your page to load LABjs itself dynamically, if you're so inclined. | |
(function (global, oDOC, handler) { | |
var head = oDOC.head || oDOC.getElementsByTagName("head"); | |
function LABjsLoaded() { | |
// do cool stuff with $LAB here | |
} |
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
char* executeProcess(char** args) { | |
int p[2], p2[2], pid, output_length = 100, current_size = 0, num_args = 3, i, child_stat; | |
bool error = false; | |
char cread; | |
char* output = NULL; | |
char** cmd_args; | |
std::string cmd(args[1]); | |
// take off args[0], since will be sent into stdin of process | |
std::string input_data(args[0]); |
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
I noticed you are hotlinking to http://labjs.com/js/LAB.js. | |
While I'm thrilled that you've found a use for LABjs, my | |
server is not a CDN and is not set up to handle the bandwidth | |
load your high traffic site is sending at it. I've added a | |
note to the file to help explain that to your users. Please | |
stop hotlinking. |
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 test_jQuery() { jQuery(""); } | |
function success_jQuery() { alert("jQuery is loaded!"); | |
var successfully_loaded = false; | |
function loadOrFallback(scripts,idx) { | |
function testAndFallback() { | |
clearTimeout(fallback_timeout); | |
if (successfully_loaded) return; // already loaded successfully, so just bail | |
try { | |
scripts[idx].test(); |
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 count_str_occurrences(str,arr) { | |
var arr_str = arr.join(","), | |
regex = new RegExp("(?:^|,)"+str+"(?:,|$)","g"), | |
tmp; | |
if (tmp = arr_str.match(regex)) { | |
return tmp.length; | |
} | |
return 0; | |
} |
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
var _flash_installed = ((typeof navigator.plugins != "undefined" && typeof navigator.plugins["Shockwave Flash"] == "object") || (window.ActiveXObject && (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) != false)); |
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
<html> | |
<head> | |
<script src="jquery-1.3.3"></script> | |
<script>var $jq133 = jQuery.noConflict(true);</script> | |
<!-- other stuff --> | |
<script src="jquery-1.4"></script> | |
<script>var $jq14 = jQuery.noConflict(true);</script> |