Skip to content

Instantly share code, notes, and snippets.

View vladimir-ivanov's full-sized avatar

vladimir ivanov vladimir-ivanov

View GitHub Profile
@vladimir-ivanov
vladimir-ivanov / .block
Last active December 5, 2016 13:38
fresh block
license: mit
@vladimir-ivanov
vladimir-ivanov / softmax.js
Created June 27, 2016 20:22
softmax function implementation in js
let softmax = (arr) => (index) => Math.exp(arr[index]) / arr.map(y => Math.exp(y)).reduce((a, b) => a + b);
@vladimir-ivanov
vladimir-ivanov / es6-get-prototype-methods.js
Last active March 9, 2016 22:40
ECMA6 Class get all methods from all inherited classes
function getClassMethods(className) {
if (!className instanceof Object) {
throw new Error("Not a class");
}
let ret = new Set();
function methods(obj) {
if (obj) {
let ps = Object.getOwnPropertyNames(obj);
@Injectable()
export class RuntimeMetadataResolverWrapper extends RuntimeMetadataResolver {
directiveResolver;
viewResolver;
_directiveCache = new Map();
constructor(_directiveResolver: DirectiveResolver, _pipeResolver: PipeResolver,
_viewResolver: ViewResolver, @Optional() @Inject(PLATFORM_DIRECTIVES) _platformDirectives, @Optional() @Inject(PLATFORM_PIPES) _platformPipes) {
super(_directiveResolver, _pipeResolver, _viewResolver, _platformDirectives, _platformPipes);
this.directiveResolver = _directiveResolver;
@vladimir-ivanov
vladimir-ivanov / md-input-wrapper.ts
Last active February 16, 2016 11:34
ng2-material md-input fix for when a value is being applied programmatically (e.g. via [value]="myValue") without typing in the input breaks the md-input-has-value class etc
import {
Directive,
View,
Component,
AfterContentInit,
ElementRef,
OnChanges,
ContentChild,
Input,
Output,
@vladimir-ivanov
vladimir-ivanov / md-autocomplete.ts
Last active May 24, 2017 12:37
angular2 material autocomplete - md-autocomplete widget (without md-virtual-repeat) to work with ng2-material
import {Component, Input, OnInit, Output, EventEmitter} from "angular2/core";
import {MdList, MdListItem, MdInput, MdInputContainer} from "ng2-material/all";
@Component({
selector: "md-autocomplete",
directives: <Array<any>>[MdList, MdListItem, MdInput, MdInputContainer],
template: `
<md-input-container>
<label>{{placeholder}}</label>
<input md-input type="search"
@vladimir-ivanov
vladimir-ivanov / md-dialog-complex.ts
Last active February 10, 2016 16:47
md-dialog sngular2 with content
import {Input, OnInit, Component, Attribute, Output, EventEmitter} from "angular2/core";
import {KeyCodes} from "ng2-material/core/key_codes";
import {OnChanges} from "../../../../node_modules/angular2/ts/src/core/linker/interfaces";
@Component({
selector: "md-dialog-advanced",
host: {
"(body:keydown)": "documentKeypress($event)"
},
template: `
@vladimir-ivanov
vladimir-ivanov / gist:3c3ef070d73301ca3ccd
Last active December 18, 2015 13:03
Fix Instructions for npm installing dependencies in Intranet with no access to Internet e.g. npm install npm ERR fetch failed https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz
How to deal with dependencies which depend on dependencies referenced with github.com rather than a version
Works for Build Servers which do not have access to the Internet, having all npm dependencies cached in local registry e.g. nexus
In case you introduce a new library or upgrade one, which relies on github.com somewhere
Fixes
npm install [email protected]
npm ERR fetch failed https://github.com/rase-/node-XMLHttpRequest/archive/a6b6f2.tar.gz
@vladimir-ivanov
vladimir-ivanov / ag-grid-render-header-cell.js
Last active January 11, 2016 11:45
ag-grid angular-grid reorder columns with drag and drop inline - drag the column heading to the desired place and drop - would be nice to get integrated within ag-grid
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
/**
* @desc - hacky way of intercepting the class (all properties and methods inside are private - just a temp solution until it gets
* added to the ag-grid functionality
*/
/// <reference path="../typings/ag-grid/ag-grid.d.ts" />
@vladimir-ivanov
vladimir-ivanov / karma.conf.js
Last active November 29, 2015 21:48
angular2 webpack config example with two chunks
const webpackConfig = require('../webpack.config.js');
module.exports = function (config) {
config.set({
basePath: '../',
files: [
'build/angular2.js',
// 'build/bundle.js',
'test/unit/app.ts',