This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isValid(inStr = '') { | |
var dictionary = { | |
'{': '}', | |
'(': ')', | |
'[': ']' | |
} | |
var stack = []; | |
inStr = inStr.split(''); | |
for (var i = 0; i < inStr.length; i++) { | |
if(!dictionary.hasOwnProperty(inStr[i]) && dictionary[stack[stack.length -1]] == inStr[i]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Test = function () { | |
this.eventsStorage = []; | |
this.loopHendler = undefined; | |
}; | |
Test.prototype.on = function (name, cb) { | |
this.eventsStorage.push({ | |
name: name, | |
fn: cb | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
---------------1-------------- | |
var a = (function(a) { | |
return function(b) { | |
return a + b; | |
} | |
})(5)(5); | |
console.log(a); | |
---------------2-------------- | |
var a = 5; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a = ['one', 'two', 'three']; | |
//what is the index of the element 'two' | |
var index = a | |
.map(function (el, index) { | |
return { | |
index: index, | |
value: el | |
}; | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const rx = require('rx'); | |
let Collection = function () { | |
this._data = []; | |
this._onPush = undefined; | |
this._observable = rx.Observable.create((observer) => { | |
this._onPush = function () { | |
observer.onNext(this._data); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function Factory(getInstance?: boolean) { | |
return function (target: any) { | |
let construct: any = function (constructor: Function, args: any[]) { | |
var model: any = function () { | |
return constructor.apply(this, args); | |
} | |
Object.keys(constructor.prototype).forEach((key:string) => { | |
Object.defineProperty(model.prototype, key, Object.getOwnPropertyDescriptor(constructor.prototype, key)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {Inject} from '../decorators/inject'; | |
import {Factory} from '../decorators/factory'; | |
export interface IModelFactory { | |
attributes: any; | |
id: string; | |
getRelation(relation?: string): ng.IPromise<any>; | |
update(): ng.IPromise<any>; | |
delete(model: IModelFactory): ng.IPromise<any>; | |
add(model?: IModelFactory): ng.IPromise<any>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const mongoose = require('mongoose'); | |
const Schema = mongoose.Schema; | |
const MD5 = require('crypto-js/md5'); | |
function setPassword(password) { | |
return this.encryptPassword(password); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ContentView = BaseView.extend({ | |
tagName:'div', | |
className: 'content', | |
views: { | |
"root": PickView, | |
"heroes": HeroesView | |
}, | |
onInitialize: function (params) { | |
//reference to the current view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DD.ui.renderer.Fields.prototype.resize = function(component) | |
{ | |
if (!component.isInDocument()) | |
return; | |
var element = component.getElement(); | |
if (element.DD_stylesheet) | |
goog.dom.removeNode(element.DD_stylesheet); | |
var content = component.getContentElement(); | |
var fields = content.children; | |
var count = fields.length; |
NewerOlder