Skip to content

Instantly share code, notes, and snippets.

View kangax's full-sized avatar

Juriy Zaytsev kangax

View GitHub Profile
@kangax
kangax / components.child-component.js
Created February 9, 2021 19:16 — forked from kshitij-srv/components.child-component.js
Ember: Access child function from parent component
import Ember from 'ember';
const {
Component, set, get
} = Ember;
export default Component.extend({
imageSource:'',
didInsertElement() {
get(this, 'setChildReference')(this);
@kangax
kangax / gist:1051534
Created June 28, 2011 16:28 — forked from maxim/progressify.rb
Progressify - a progress bar approximator for smoothness
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Progressify</title>
<script>
var Plot = (function() {
function Point(duration, progress) {
this.duration = duration;
/**
* Provides requestAnimationFrame in a cross browser way.
* @author greggman / http://greggman.com/
*/
if (!window.requestAnimationFrame) {
window.requestAnimationFrame =
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
var query = (function() {
var query, engine, engines = ('NW.Dom.select,base2.dom.querySelectorAll,Sizzle,$$,$,jQuery,'+
'YAHOO.util.Selector.query,dojo.query,Ext.DomQuery.select,document.querySelectorAll').split(',');
while (engine = engines.shift()) {
if (Function('try{ var els = ' + engine + '("*"); return els.length > 0 }catch(e){}')()) {
query = Function('cssExpr', 'return ' + engine + '(' +
(/^base2/.test(engine) ? 'document,' : '') + 'cssExpr)');
break;
}
// @kangax fix yur SubArray (ES5 flavor) kthxbai
// http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/#ecmascript_5_accessors_to_the_rescue

// (C) Juriy Zaytsev (aka @kangax) - MIT Style License
// http://perfectionkills.com/how-ecmascript-5-still-does-not-allow-to-subclass-an-array/

var SubArray = (function() {

  var MAX_SIGNED_INT_VALUE = Math.pow(2, 32) - 1,

hasOwnProperty = {}.hasOwnProperty,

/**
* Aliases and additional "sugar"
* 2010-04-15
* @author Dmitry A. Soshnikov
*/
(function () {
["defineProperty", "defineProperties", "keys", "getOwnPropertyNames",
"getOwnPropertyDescriptor", "getPrototypeOf", "seal", "freeze",
"preventExtensions", "isFrozen", "isSealed", "isExtensible"]
/* MODIFY PROTOTYPE */
var _fn=function(){};
_fn.prototype.a=1;
var v=new _fn();
alert(v.a === 1); /* true */
alert(v.constructor === _fn); /* true */
/* REPLACE PROTOTYPE */
We couldn’t find that file to show.
@kangax
kangax / gist:247885
Created December 3, 2009 04:25 — forked from lsmith/gist:247884
<script>
/* Alternate snippet to asynchronously embed the Google Analytics script.
* This requires the following things of the pages that will contain it:
* 1. the page only include one GA tracker (common case),
* 2. the page is not be behind SSL (http, not https),
* 3. this script block can be in the <head> or <body> elements
*/
var _gaq = [['_setAccount', 'UA-XXXXXX-X'],['_trackPageview']];
(function(d) {
/**
* Example:
* 'hello {{username}}'.between('{{','}}') === 'username'
*/
String.prototype.between_regexp = function between(begin, end) {
var regexp = new RegExp(begin + '(.+)' + end);
return this.match(regexp)[1];
}