Skip to content

Instantly share code, notes, and snippets.

View termi's full-sized avatar

Егор Халимоненко termi

View GitHub Profile
@Raynos
Raynos / clone.js
Created August 9, 2012 02:24
A proper clone
// example: http://jsfiddle.net/QVqHs/
function clone(o) {
return Object.create(
Object.getPrototypeOf(o),
getOwnPropertyDescriptors(o)
)
}
function getOwnPropertyDescriptors(o) {
@RubaXa
RubaXa / gist:4084463
Created November 16, 2012 05:33
xtpl vs. fest

Fest

<?xml version="1.0"?>
<fest:template xmlns:fest="http://fest.mail.ru" context_name="json">
	<div class="elm">
		<fest:attributes>
			<fest:attribute name="id">box</fest:attribute>
			<fest:attribute name="style">color: red;</fest:attribute>
			<fest:attribute name="class"><fest:space/>js-elm</fest:attribute>
/**
* jQuery event "tap" (Based on https://developers.google.com/mobile/articles/fast_buttons)
*
* @author RubaXa <trash@rubaxa.org>
* @license MIT
*/
(function (window, $){
var
support = window.TapSupportEnabled && ('ontouchstart' in window) || window.DocumentTouch && document instanceof DocumentTouch
@bobslaede
bobslaede / modernizr.positionfixed.js
Created September 16, 2011 08:50
Modernizr position fixed check
;(function(Modernizr, window) {
Modernizr.addTest('positionfixed', function () {
var test = document.createElement('div'),
control = test.cloneNode(false),
fake = false,
root = document.body || (function () {
fake = true;
return document.documentElement.appendChild(document.createElement('body'));
}());
@WebReflection
WebReflection / Object.getOwnPropertyDescriptors.js
Created March 3, 2014 01:39
A plural ES5 + ES6 friendly version of Object.getOwnPropertyDescriptor
'getOwnPropertyDescriptors' in Object || (
Object.getOwnPropertyDescriptors = function (Object) {
var
gOPD = Object.getOwnPropertyDescriptor,
gOPN = Object.getOwnPropertyNames,
gOPS = Object.getOwnPropertySymbols,
gNS = gOPS ? function (object) {
return gOPN(object).concat(gOPS(object));
} :
gOPN,
/**
* User Timing polyfill (http://www.w3.org/TR/user-timing/)
* @author RubaXa <trash@rubaxa.org>
*/
(function (window){
var
startOffset = Date.now ? Date.now() : +(new Date)
, performance = window.performance || {}
, _entries = []
@eligrey
eligrey / outerHTML.js
Created June 24, 2011 02:56
Efficient outerHTML polyfill that doesn't use cloneNode(true)
/*
* outerHTML.js
* Cross-browser full HTMLElement.outerHTML implementation.
*
* 2011-11-14
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@Raynos
Raynos / weak-map.js
Last active September 18, 2019 07:49 — forked from Gozala/weak-map.js
Harmony WeakMap shim for ES5
// Original - @Gozola. This is a reimplemented version (with a few bug fixes).
window.WeakMap = window.WeakMap || (function () {
var privates = Name()
return {
get: function (key, fallback) {
var store = privates(key)
return store.hasOwnProperty("value") ?
store.value : fallback
},
@indexzero
indexzero / readme-outline.md
Created November 14, 2011 08:26
A quick outline of a README.md

README.md Outline

  • Header and a Brief description (should match package.json)
  • Example (if applicable)
  • Motivation (if applicable)
  • API Documentation: This will likely vary considerably from library to library.
  • Installation
  • Tests
  • Contributors
  • License
@Zirak
Zirak / gist:1677020
Created January 25, 2012 16:15
Visibility API
//http://www.w3.org/TR/2011/WD-page-visibility-20110602/
(function () {
"use strict";
//no need to shim if it's already there
if ( 'hidden' in document && 'onvisibilitychange' in document ) {
return;
}
//fail silently if the browser sux