Skip to content

Instantly share code, notes, and snippets.

View savelee's full-sized avatar

Lee Boonstra savelee

View GitHub Profile
@savelee
savelee / .js
Created June 27, 2016 17:19
Ext JS 6.2 - custom D3: scenesetup: function(component, scene){ .. }
var store = Ext.getStore('Artists');
var max = store.getCount();
var i = 0, data = [], artists = [];
//I need two arrays, one with artist names, and one with playcounts. In my first try, I hardcoded it. Afterwards, I switched to a real store.
for(i; i<max; i++){
artists.push(store.getAt(i).get('name'));
data.push(store.getAt(i).get('playcount'));
}
@savelee
savelee / Chart.js
Last active June 27, 2016 17:20
Out of the box Ext JS 6.2 - D3 implementation
Ext.define('Dashboard.view.contacts.Chart', {
extend: 'Ext.d3.svg.hierarchy.tree.HorizontalTree',
xtype: 'departments-chart',
requires: [
'Ext.d3.interaction.PanZoom'
],
nodeSize: [20, 70],
bind: {
store: '{department}',
selection: '{selection}'
@savelee
savelee / js
Created July 13, 2016 13:01
CustomProxy
Ext.define('Engine.model.LastFmResult', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.identifier.Sequential',
'SenchaCandyShared.proxy.lastfm.LastFm'
],
identifier: {
type: 'sequential',
@savelee
savelee / new.js
Last active July 25, 2016 13:56
Lexical This
//ES2015
function VideoGame(){
this.title = "Uncharted";
this.version = 3;
setInterval(() => {
console.log(this.title + " " + this.version++); // |this| properly refers to the VideoGame object
}, 5000);
}
@savelee
savelee / new.js
Last active July 25, 2016 13:59
Arrow Functions: No arguments object, since arrow functions have no arguments binding, you must rely on named and rest parameters to access function arguments.
//ES2015
var foo = (x,y) => arguments[0];
foo("lee","2") //ReferenceError: arguments is not defined [Learn More]
@savelee
savelee / new.js
Last active July 25, 2016 14:00
Arrow Functions: No duplicate named arguments. Arrow functions cannot have duplicate named arguments in strict or nonstrict mode, as opposed to non-arrow functions that cannot have duplicate named arguments only in strict mode
//ES2015
var x = (x,x) => x;
//SyntaxError: duplicate argument names not allowed in this context
@savelee
savelee / new.js
Last active July 25, 2016 14:02
Example of Arrow Functions
//ES6 arrow functions
var calculate = (x,y) => {
return x + y;
}
var sayHello = (name) => {
return "Hello " + name;
}
//or:
@savelee
savelee / new.js
Last active July 25, 2016 14:04
Example of template literals
//ES2015
let product = "Sencha";
let myText = `${product} provides the industry's most comprehensive collection of high-performance, customizable UI widgets.
These "widgets" include HTML5 grids, trees, lists, forms, menus, toolbars, panels, windows, and much more.
If you don't find a widget you are looking for, hundreds of user extensions are available from the Sencha community.`;
@savelee
savelee / taggedtemplate.js
Last active July 25, 2016 14:05
Example Tagged Templates (template functions)
//ES2015
function myTag(arrLiterals){
return arrLiterals[0].toUpperCase();
}
let message = myTag`hello world!`; //HELLO WORLD!
@savelee
savelee / new.js
Last active July 25, 2016 14:06
Example default parameters
//ES2015
function makeRequest(url, timeout = 2000, callback = function(){}) {
//do something
}