Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
View terminal-control.sh
# Terminal output control (http://www.termsys.demon.co.uk/vtansi.htm)
TC='\e['
CLR_LINE_START="${TC}1K"
CLR_LINE_END="${TC}K"
CLR_LINE="${TC}2K"
# Hope no terminal is greater than 1k columns
RESET_LINE="${CLR_LINE}${TC}1000D"
@neopunisher
neopunisher / Rpi.sh
Created Feb 3, 2014
Rasberry Pi Bash Cheatsheet
View Rpi.sh
sudo mkdir /mnt/usbdrive
sudo mount /dev/sda1 /mnt/usbdrive
sudo umount /dev/sda1
OR
sudo umount /mnt/usbdrive
View WiFi_automatic_installation.sh
#!/bin/bash
# A very crude script to setup debian6-19-04-2012 to use Realtek RRTL8188CUS based Wireless LAN Adapters
# Update: 20/05/2012 - It is no longer necessary to edit the script to setup the network SSID & PASSWORD
# The script will ask you to input these values when it needs them.
# Update: 25/05/2012 - I have added an option to enable the wifi adapter to be hotpluggable.
# i.e. you can remove the adapter while the Pi is powered on and then plug it back in later
View grab_facebook.js
JSON.parse(unescape(document.querySelectorAll('embed')[0].attributes.getNamedItem('flashvars').value).substr(7).split('&width')[0]).video_data[0].hd_src
View curl-multi.php
<?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 Sep 8, 2011
Unique Year from XSL
View uniqueyear.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 Sep 9, 2011
Crossfade list elements
View crossfade.js
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 Sep 12, 2011
Google analytics event tracking w/ jQuery
View eventracking.js
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 Sep 12, 2011
Word break inserter w/ javascript
View longwordbreak.js
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 Sep 26, 2011
A function to mixin to _ that throttles API calls
View _throttleApi.js
_.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))}}});