Skip to content

Instantly share code, notes, and snippets.

Avatar

Sultan thysultan

View GitHub Profile
@thysultan
thysultan / index.html
Created Jul 24, 2012
A web page created at CodePen.io.
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>simple minimal calculator &middot; CodePen</title>
<!--
Copyright (c) 2012 Sultan Tarimo, http://codepen.io/sultantarimo
Permission is hereby granted, free of charge, to any person obtaining
View $.ajaxPagination.js
$.ajaxPagination = function(el, container, e){
e.preventDefault();
var oldLink, newLink, selectors, page;
el = $(el);
selectors = {
loading: "loading",
pageName: "data-page-name",
View grid.css
/**
* Grid
*
* useage:
// 25% vs 75%
<div class="grid-row">
<div class="grid-span-1/4"></div>
<div class="grid-span-3/4"></div>
</div>
View gist:97807e466ef78d63ed073c81733b17da

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})
@thysultan
thysultan / HEY-YOU.md
Created Apr 23, 2016 — forked from cowboy/HEY-YOU.md
jQuery Tiny Pub/Sub: A really, really, REALLY tiny pub/sub implementation for jQuery.
@thysultan
thysultan / jquery-pubsub.js
Created Apr 23, 2016 — forked from bentruyman/jquery-pubsub.js
Simple Pub/Sub Implementation for jQuery
View jquery-pubsub.js
/*
* Simple Pub/Sub Implementation for jQuery
*
* Inspired by work from Peter Higgins (https://github.com/phiggins42/bloody-jquery-plugins/blob/master/pubsub.js)
*
* This is about the simplest way to write a pubsub JavaScript implementation for use with jQuery.
*/
(function( $ ) {
// Cache of all topics
View gist:9c4a74abdbc76a1d8572823c95cf3d16
// model
function Model () {
this._state = {}
return this
}
Model.prototype.get = function (key) {
return this._state[key]
}
@thysultan
thysultan / dom-to-json.js
Created Jun 11, 2016 — forked from Thaina/dom-to-json.js
Stringify DOM nodes using JSON (and revive again)
View dom-to-json.js
/** @param {Node|HTMLElement} node */
function toJSON(node) {
if(!node)
node = this;
var obj = { nodeType: node.nodeType };
if(node.tagName)
obj.tagName = node.tagName.toLowerCase();
else if(node.nodeName)
@thysultan
thysultan / memorySizeOfObject.js
Last active Jun 13, 2016 — forked from zensh/memorySizeOfObject.js
calculate memory size of javascript object, it is not a accurate value!
View memorySizeOfObject.js
function memory(obj) {
var bytes = 0;
function size (obj) {
if (obj !== null && obj !== undefined) {
switch (typeof obj) {
case 'number': bytes += 8; break;
case 'string': bytes += obj.length * 2; break;
case 'boolean': bytes += 4; break;
case 'object':
@thysultan
thysultan / stack.js
Created Jun 13, 2016
try to push to the end of the event stack
View stack.js
requestAnimationFrame(function () {
setTimeout(function () {
fn()
}, 0)
})
You can’t perform that action at this time.