Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
<?php
define('EMAIL', 'test@example.com'); // edit this
define('FLICKR_API_KEY', ''); // edit this
define('RAPLEAF_API_KEY', ''); // edit this
define('USER_AGENT', 'example user agent (http://www.example.com)'); // edit this
define('COOKIE_FILE', '/tmp/cookies.txt'); // edit this if needed
@neopunisher
neopunisher / uniqueyear.xsl
Created September 8, 2011 18:16
Unique Year from XSL
<xsl:key name="myYear" match="/IRXML/NewsReleases/NewsCategory/NewsRelease" use="substring(Date/@Date,1,4)"/>
<xsl:template name="yearDropDown">
<xsl:for-each select="/IRXML/NewsReleases/NewsCategory/NewsRelease[generate-id() = generate-id(key('myYear',substring(Date/@Date,1,4))[1])]">
<xsl:sort select="Date/@Date" data-type="text" order="descending" />
<xsl:value-of select="generate-id()"/> |
<xsl:value-of select="Date/@Date"/><br />
</xsl:for-each>
</xsl:template>
@neopunisher
neopunisher / crossfade.js
Created September 9, 2011 17:45
Crossfade list elements
function loopnews(){
var $active = jQuery('div.newsTicker>ul>li.active'),
$next = $active.next('li');
//console.log($next);
if($next.length != 1){
$next = jQuery('div.newsTicker>ul>li:eq(0)')
}
$active.fadeOut(500,function(){
$active.removeClass('active');
$next.addClass('active').fadeIn(1000,function(){
@neopunisher
neopunisher / eventracking.js
Created September 12, 2011 15:45
Google analytics event tracking w/ jQuery
jQuery(function(){
jQuery('a[href$=".pdf"]').click(function(){
_gat._getTrackerByName()._trackEvent('Download', 'Pdf', this.href);
setTimeout('document.location = "' + this.href + '"', 100);
return false
});
jQuery('a[href$=".exe"]').click(function(){
_gat._getTrackerByName()._trackEvent('Download', 'Exe', this.href);
@neopunisher
neopunisher / longwordbreak.js
Created September 12, 2011 20:21
Word break inserter w/ javascript
function wbr(str, num) { if(num == undefined) num = 3;
return str.replace(RegExp("(\\w{" + num + "})(\\w)", "g"), function(all,text,char){
return text + "<wbr>" + char;
});
}
@neopunisher
neopunisher / _throttleApi.js
Created September 26, 2011 00:46
A function to mixin to _ that throttles API calls
_.mixin({throttleApi:function(m,g,h,d){var j=function(a){var i=new Date;_.isUndefined(a)||i.setSeconds(i.getSeconds()+a);return i},b=[],e=0,f=0,c=null,l=j(1),k=function(a){console.log("rundo");if(b.length==0)console.log("queue empty".yellow),clearTimeout(c),c=null;else{a=[];if(g){l<j()&&(console.log("reset timer...".yellow),f=0,l=j(1));if(f==g)return;a.push(g-f)}if(h){if(e==h)return;a.push(h-e)}a.push(b.length);a=_.min(a);console.log("i run:"+a);_.times(a,function(){f++;e++;var a=b.shift();_.isUndefined(d)&&
(d=_.compact(_.map(a,function(a,b){return _.isFunction(a)?b:!1}))[0]);var c=a[d];a[d]=function(){e--;b.length>0&&_.defer(k);c.apply(this,_.toArray(arguments))};m.apply(null,a)});_.isNull(c)&&b.length>0&&(console.log("setting timer".yellow),c=setInterval(k,500))}};return function(){console.log("pushing args".yellow);b.length==0&&_.defer(k);b.push(_.toArray(arguments))}}});
@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 / sendemail.asp
Created September 27, 2011 18:57
Classic ASP send email
sub sendemail(subject,body,sto)
Set objMessage = CreateObject("CDO.Message")
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.gmail.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = "no-reply@brandextract.com"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "passwd" ' change thus
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
objMessage.Configuration.Fields.Update
@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)})();