Skip to content

Instantly share code, notes, and snippets.

@rickycodes
rickycodes / jQ protobot
Created May 31, 2012 06:13
jQuery API calls for protobot
// jQuery API
j.watch_for( /^\?([^#@]+)(?:\s*#([1-9]))?(?:\s*@\s*([-\[\]|_\w]+))?$/, function( message ) {
// Return if botty is present
if ( message.source.clients.indexOf( 'bot-t' ) >= 0 || message.source.clients.indexOf( 'bot-t1' ) >= 0 )
return
var splat = message.text[ 0 ].split( ' ' )
, s = splat[ 0 ].replace( '?', '' )
, to = ( splat[ 1 ] === '@' && splat[ 2 ] && splat.length === 3 ) ? splat[ 2 ] : ''
@rickycodes
rickycodes / jQuerylol
Created June 25, 2012 19:57
best jQuery plugin evar
(function($) {
$.fn.ಠ_ಠ = $.fn.ಥ_ಥ = $.fn.ಠ益ಠ = $.fn.ಥ益ಥ = $.fn.ಠ_ರೃ = $.fn.ಠoಠ = $.fn.ಠxಠ = $.fn.囧 = function() {
return this;
};
})(jQuery);​
@rickycodes
rickycodes / gist:4004078
Created November 2, 2012 20:19
flipString kickFlip
function flipString( str ) {
return str.toLowerCase().split( '' ).map( function( c ) {
return chars[ c ] ? chars[ c ] : c
}).reverse().join('')
}
function kickFlip( str ) {
return '(╯°□°)╯︵' + flipString( str )
}
@rickycodes
rickycodes / gist:4125586
Created November 21, 2012 15:51
Greyscale a thing
.thing {
filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale");
filter: gray;
-webkit-filter: grayscale(100%);
}
@rickycodes
rickycodes / gist:4504670
Created January 10, 2013 18:45
multiline flair.js
/**
* @module flair
*/
const irc = require( "irc-js" )
const FLAIR =
[ [ /\balligator\b/i, "---,==,'<" ]
, [ /\bshrugs\b/i, "¯\\_(ツ)_/¯" ]
, [ /\by u\b/i, "(屮'Д')屮" ]
, [ /\bdentata\b/i, [ "(▼▼▼▼▼▼▼▼▼)"
var gol = [ " _,...,_"
, " .'@/~~~\\@'."
, " //~~\\___/~~\\\\"
, "|@\\__/@@@\\__/@|"
, "|@/ \\@@@/ \\@|"
, " \\__/~~~\\__//"
, " '.@\\___/@.'" ];
@rickycodes
rickycodes / gist:4552795
Last active December 11, 2015 05:29
desc ircjsbot plugin
/**
* @module desc
* This module fetches titles + descriptions for sites shared in a channel IF the message is simply an URL
* This module is also an example of how to use cheerio to `parse` html.
* Dependencies not included in ircjsbot: cheerio + request (request because it follows redirects, which the entire internet is build on, apparently)
*/
"use strict";
const irc = require("irc-js");
@rickycodes
rickycodes / gist:4676800
Created January 30, 2013 20:47
b-ot uptime
function uptime(msg) {
var s = process.uptime();
const h = Math.floor( s / ( 60 * 60 ) );
s -= h * ( 60 * 60 );
const m = Math.floor( s / 60 );
s -= m * 60;
msg.reply('I have been running for %s hours, %s minutes and %s seconds.', h, m, s);
}
@rickycodes
rickycodes / gist:4732521
Last active December 12, 2015 06:49
Cache bust your apps
$(function(){
var bust = Date().now();
var resources = [
{ html : '<script>', attr : 'src', link : 'js/init.js?v=' }
, { html : '<link rel="stylesheet">', attr : 'href', link : 'css/style.css?v=' }
];
$.each(resources, function(i,v) {
$(v.html).attr(v.attr, v.link + bust).appendTo( 'body' );
});
@rickycodes
rickycodes / gist:10682109
Last active August 29, 2015 13:59
alignment for facespac.es
(function(){
var css = '#video-wrapper table {';
css+= 'width: 101px;';
css+= 'height: 101px;';
css+= 'border: 1px solid red;';
css+= 'position: absolute;';
css+= 'top: 0;';
css+= 'z-index: 999;';
css+= '}';