Skip to content

Instantly share code, notes, and snippets.

@rkatic
rkatic / Readme.md
Created September 22, 2010 12:12
Userscript that auto appends things in reddit.

###Reddddit

Auto appends things scrolling down the page eliminating the need to click the next link.

##Install/Update

To toggle Auto Appending, click on the respective link near your username (above the login form). The asteriks near that toggler opens this page so you can easily check for new versions (specially if reddit changes).

Script will also check daily if there is a new version of it worth of user attention.

@rkatic
rkatic / debounce-example.md
Created January 21, 2011 12:00
Timer with less clear/setTimeout calls...
$(window).bind('mousemove mousedown mouseup scroll keydown keyup focus', debounce(10E3, function() {
	// idle
}));
jQuery._Deferred = function() {
var // callbacks list
callbacks = [],
// stored [ context , args ]
fired,
// to avoid firing when already doing so (or it is halted)
firing,
// flag to know if the deferred has been cancelled
cancelled,
// the deferred itself
@rkatic
rkatic / isArguments.js
Created April 30, 2011 07:00
isArguments
// Cross-browser but not absolutely strong.
function isArguments( obj ) {
return typeof obj === "object" && ( "callee" in obj ) && typeof obj.length === "number";
}
// Ideally strong, but broken on Opera...
var isArguments = (function( undefined ) {
@rkatic
rkatic / private.js
Last active September 25, 2015 23:08
Private members hack...
function Private() {
var val, NADA = {};
return {
open: function( safe, ret ) {
val = NADA;
safe();
if ( val !== NADA ) {
ret = val;
val = NADA;
@rkatic
rkatic / isNativeObject.js
Created June 3, 2011 10:25
A robust isNativeObject()
var isNativeObject = (function( window ){
var a = "Boolean Number String Function Array Date RegExp Object".split(" "),
natives = {},
hostTypes = {
"object": 1,
"function": 1
},
@rkatic
rkatic / nativeType.jquery.js
Created August 28, 2011 15:03
Object type inquiry enhancments via $.nativeType()
(function( jQuery, undefined ){
var toString = ({}).toString,
hasOwn = ({}).hasOwnProperty,
slice = [].slice,
push = [].push,
// [[Class]] --> type (for all natives)
class2type = {},
var formCheckedRadios = {};
function OldWebKitFakeRadio() {
this._name = "";
this._defaultChecked = false;
this._checked = false;
}
OldWebKitFakeRadio.prototype = {
get name() {
@rkatic
rkatic / later.js
Last active January 19, 2021 07:31
Cross-browser and optimized way to postpone a function execution to next "tick".
// Based on the Q.nextTick implementation https://github.com/kriskowal/q/pull/195.
var later = (function(){
var head = { task: void 0, next: null }, tail = head,
maxPendingTicks = 2, pendingTicks = 0, queuedTasks = 0, usedTicks = 0,
requestTick;
var onTick = function() {
--pendingTicks;
if ( ++usedTicks >= maxPendingTicks ) {
// array already sorted!
function unique( array ) {
var j = 0,
i = 1,
l = array.length | 0;
while ( i < l && array[i-1] !== array[i] ) {
++i;
}