Skip to content

Instantly share code, notes, and snippets.

View neopunisher's full-sized avatar
🎯
Focusing

Carter Cole neopunisher

🎯
Focusing
View GitHub Profile
@anwajler
anwajler / readstream.js
Created May 22, 2011 15:47
Node.js ReadStream
var path = '/tmp/read-simple.txt';
var options = { flags: 'r',
encoding: 'utf-8',
mode: 0666,
bufferSize: 1024,
start: 0,
end: 100
};
var dataReceived = function(data) {
console.log(data);
repo for a more modern version of qt (4.7)
http://atrpms.net/documentation/install/
http://packages.atrpms.net/dist/el5/qt4/
cat /etc/yum.repos.d/atrpms.repo
[atrpms]
name=ATrpms manual
baseurl=http://dl.atrpms.net/el5-$basearch/atrpms/testing/
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
@smcllns
smcllns / gist:1136488
Created August 10, 2011 10:01
Tracking outbound links with Google Analytics
< script type = "text/javascript" >
(function($) {
$(function() {
$('a[href^="http"]:not([href*="' + document.domain + '"])').click(function(e) {
// When a user clicks an external link
if ($(this).attr('target') !== '_blank') {
e.preventDefault();
@slyphon
slyphon / socksproxy.js
Created August 15, 2011 23:16 — forked from telamon/socksproxy.js
Socks5 proxy implementation in Node.JS
// http://www.ietf.org/rfc/rfc1928.txt
// Tested with: curl http://www.google.se/ --socks5 1080 --proxy-user foo:bar
var States = {
CONNECTED:0,
VERIFYING:1,
READY:2,
PROXY: 3
};
@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 / 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 / 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]]};