Skip to content

Instantly share code, notes, and snippets.

Ivan V. ivandotv

  • Novi Sad, Serbia
Block or report user

Report or block ivandotv

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ivandotv / element_in_view.js
Created Jun 4, 2018
Detect when element is in view optionally using Intersection Observer
View element_in_view.js
(function ($, window, document, undefined) {
var pluginName = "elementInView",
defaults = {
visibleWhenRatio: 0,
cb: $.noop,
outsideViewCallback: $.noop,
debounce: 100,
onlyOnce: true
View inheritsOLOO.js
window.ikiThemes.Utils = (function ($) {
return {
inherits: function inherits(ctor, superCtor) {
ctor.super_ = superCtor;
ctor.prototype = Object.create(superCtor.prototype);
inheritsOLOO: function (superCtor) {
var o = Object.create(superCtor);
ivandotv / gist:10023824
Last active Aug 29, 2015
Ladda bootstrap integration with Angular
View gist:10023824
angular.module('uiElements', []).directive('ikiLadda', [function () {
if (typeof Ladda === 'undefined') {
throw new Error('Ladda Library Missing');
// Ladda also depends on Spinner and it will throw error if that library is not present.
return {
ivandotv / Implementation.js
Created Nov 18, 2013
Here's a template I sometimes use for OOP-similar behavior in JavaScript. As you can see, you can simulate private (both static and instance) members using closures. What new MyClass() will return is an object with only the properties assigned to the this object and in the prototype object of the "class." As you can see, the classes correctly in…
View Implementation.js
var bob = new MyClass();
bob.announce(); // id is 1, name shows as "Bob"
var john = new MyChildClass('Doe');
john.announce(); // id is 2, name shows as "John Doe"
alert(john instanceof MyClass); // true
ivandotv / Function Hoisting.js
Created Sep 2, 2013
As you know, all variables, no matter where in the function body they are declared, get hoisted to the top of the function behind the scenes. The same applies for functions because they are just objects assigned to variables. The only “gotcha” is that when using a function declaration, the definition of the function also gets hoisted, not only i…
View Function Hoisting.js
/ antipattern
// for illustration only
// global functions
function foo() {
alert('global foo');
function bar() {
alert('global bar');
function hoistMe() {
View Function expressions
// this is a function expression,
// pased as an argument to the function `callMe`
callMe(function () {
// I am an unnamed function expression
// also known as an anonymous function
Background | 59
// this is a named function expression
callMe(function me() {
// I am a named function expression
View Javascript memoization
var myFunc = function (param) {
if (!myFunc.cache[param]) {
var result = {};
// ... expensive operation ...
myFunc.cache[param] = result;
return myFunc.cache[param];
// cache storage
myFunc.cache = {}
ivandotv / functions.php
Created Jul 8, 2013
Aktivacija plugina samo ako ga tema explicitno podrzava.
View functions.php
function theme_setup()
View instrument-hooks.php
Plugin Name: Instrument Hooks for WordPress
Description: Instruments Hooks for a Page. Outputs during the Shutdown Hook.
Version: 0.1
Author: Mike Schinkel
Author URI:
if (isset($_GET['instrument']) && $_GET['instrument']=='hooks') {
You can’t perform that action at this time.