Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
@neopunisher
neopunisher / node-uncaughtException.js
Created September 27, 2011 03:23
On error resume next of node
process.on('uncaughtException', function (err) {
console.log('Caught exception: ' + err);
});
@neopunisher
neopunisher / listCheckboxTree.js
Created September 29, 2011 17:43
list checkbox tree with indeterminate
jQuery.fn.reverse=[].reverse;jQuery(".nc>input:checkbox").click(function(){$this=jQuery(this);$this.parent().find("ol").find("input:checkbox").attr("checked",$this.is(":checked"))});
jQuery("input:checkbox").click(function(){jQuery(this);jQuery("li.nc>input:checkbox").reverse().each(function(b,d){var a=jQuery(d),c=a.parent().find("input.cu");a.attr("rel",b);a.prop("indeterminate",!1);c.length==c.filter(":checked").length?(console.log("all checked:"+b),a.attr("checked",!0)):c.length==c.filter(":not(:checked)").length?(console.log("all unchecked:"+b),a.attr("checked",!1)):(console.log("indeterminate:"+b),a.prop("indeterminate",!0))})});
@neopunisher
neopunisher / injectjQuery.js
Created October 13, 2011 18:20
jQuery injection
(function(){var a=document.createElement("script");a.type="text/javascript";a.src="http://j.mp/latestjquery";(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(a)})();
@neopunisher
neopunisher / Title-Caps.js
Created October 16, 2011 19:03
Title caps a string ignoring common words: a an and ect...
/*
* Title Caps
*
* Ported to JavaScript By John Resig - http://ejohn.org/ - 21 May 2008
* Original by John Gruber - http://daringfireball.net/ - 10 May 2008
* License: http://www.opensource.org/licenses/mit-license.php
*/
(function(){
var small = "(a|an|and|as|at|but|by|en|for|if|in|of|on|or|the|to|v[.]?|via|vs[.]?)";
@neopunisher
neopunisher / ytsecs.js
Created October 21, 2011 14:06
Format youtube seconds from api
function ytsec(a){var b=Math.floor(a/3600),c=Math.floor((a-b*3600)/60),a=a-b*3600-c*60;return(b>0?b+":":"")+(c<10?"0"+c:c)+":"+(a<10?"0"+a:a)};
@neopunisher
neopunisher / bytelbl.js
Created December 9, 2011 05:51
Pretty Bytes
function bSze(a){if(a==0)return"n/a";var b=parseInt(Math.floor(Math.log(a)/Math.log(1024)));return Math.round(a/Math.pow(1024,b),2)+" "+["Bytes","KB","MB","GB","TB"][[b]]};
@neopunisher
neopunisher / animLoopX.js
Created December 22, 2011 20:44 — forked from louisremi/animLoopX.js
Animation loop with requestAnimationFrame
// Cross browser, backward compatible solution
(function( window, Date ) {
// feature testing
var raf = window.mozRequestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.msRequestAnimationFrame ||
window.oRequestAnimationFrame;
window.animLoop = function( render, element ) {
var running, lastFrame = +new Date;
@neopunisher
neopunisher / makefileoptbox.asp
Created January 19, 2012 20:15
Uses fso to make select box options for classic asp
function makeoptboxfile(folder,def)
Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
Set objFolder = objFSO.GetFolder((folder))
For Each objItem In objFolder.Files
addit = ""
if objItem.Name = def then addit = " selected"
makeoptboxfile = makeoptboxfile & vbcrlf & "<option value='" & objItem.Name & "'" & addit & ">" & objItem.Name & "</option>"
Next
end function
@neopunisher
neopunisher / gist:3151561
Created July 20, 2012 16:02
XSL text output escape
<xsl:text disable-output-escaping="yes">
<![CDATA[
]]>
</xsl:text>
<xsl:choose>
<xsl:when test="/SAM/page/@id = $myHomePageID">
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>