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.

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 / 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 / shallowEquality.js
Last active November 10, 2015 22:33
shallow equality
/*eslint-env es6*/
const hasOwn = ({}).hasOwnProperty;
// Check if two objects are equal by comparing own enumerable properties.
const isEqualShallow = (a, b) => {
if (a === b) return true;
if (!a || !b) return false;
const akeys = Object.keys(a);
const bkeys = Object.keys(b);
// array already sorted!
function unique( array ) {
var j = 0,
i = 1,
l = array.length | 0;
while ( i < l && array[i-1] !== array[i] ) {
++i;
}
@rkatic
rkatic / gist:5309285
Last active December 15, 2015 19:09
Some utility/example functions for sequential processing with Q.
function loop (fn, startValue) {
var deferred = Q.defer(),
finished = false;
function end (val) {
finished = true;
deferred.resolve(val);
}
var asap = require("asap")
asap.sub = function (onerror) {
var parent = this;
var self = function (task) {
parent(function () {
try {
task();