Skip to content

Instantly share code, notes, and snippets.

View lmcarreiro's full-sized avatar

Leonardo Carreiro lmcarreiro

View GitHub Profile
@lmcarreiro
lmcarreiro / getSyntaxKindName.ts
Created November 18, 2017 14:24
Convert SintaxKind marker name to the real kind name
export function getSyntaxKindName(kind: SyntaxKind): string
{
const markers: { [name: string]: string } = {
FirstAssignment : "EqualsToken",
LastAssignment : "CaretEqualsToken",
FirstCompoundAssignment : "PlusEqualsToken",
LastCompoundAssignment : "CaretEqualsToken",
FirstReservedWord : "BreakKeyword",
LastReservedWord : "WithKeyword",
@lmcarreiro
lmcarreiro / grid-columns.js
Last active March 26, 2018 10:31
Grid Columns Column-Indented
const columns = [
{ name: 'id' , index: 'id' , width: 55 },
{ name: 'invdate', index: 'invdate' , width: 90 },
{ name: 'name' , index: 'name asc, invdate', width: 100 },
{ name: 'amount' , index: 'amount' , width: 80 , align: "right" },
{ name: 'tax' , index: 'tax' , width: 80 , align: "right" },
{ name: 'total' , index: 'total' , width: 80 , align: "right" },
{ name: 'note' , index: 'note' , width: 150, sortable: false }
];
@lmcarreiro
lmcarreiro / grid-columns.js
Last active March 21, 2018 17:51
Grid Columns non-indented
const columns = [
{ name: 'id', index: 'id', width: 55 },
{ name: 'invdate', index: 'invdate', width: 90 },
{ name: 'name', index: 'name asc, invdate', width: 100 },
{ name: 'amount', index: 'amount', width: 80, align: "right" },
{ name: 'tax', index: 'tax', width: 80, align: "right" },
{ name: 'total', index: 'total', width: 80, align: "right" },
{ name: 'note', index: 'note', width: 150, sortable: false }
];
@lmcarreiro
lmcarreiro / grid-columns.js
Last active March 21, 2018 17:50
Grid Columns with line-breaks
const columns = [
{
name: 'id',
index: 'id',
width: 55
},
{
name: 'invdate',
index: 'invdate',
width: 90
@lmcarreiro
lmcarreiro / imports.js
Created March 19, 2018 03:53
JS imports not column-indented
import { Schemas } from 'vs/base/common/network';
import { IProcessEnvironment , isMacintosh } from 'vs/base/common/platform';
import { TPromise } from 'vs/base/common/winjs.base';
import { whenDeleted } from 'vs/base/node/pfs';
import { IChannel } from 'vs/base/parts/ipc/common/ipc';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ParsedArgs , IEnvironmentService } from 'vs/platform/environment/common/environment';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ILogService } from 'vs/platform/log/common/log';
import { IURLService } from 'vs/platform/url/common/url';
@lmcarreiro
lmcarreiro / imports.js
Created March 19, 2018 03:55
JS imports column-indented
import { Schemas } from 'vs/base/common/network' ;
import { IProcessEnvironment , isMacintosh } from 'vs/base/common/platform' ;
import { TPromise } from 'vs/base/common/winjs.base' ;
import { whenDeleted } from 'vs/base/node/pfs' ;
import { IChannel } from 'vs/base/parts/ipc/common/ipc' ;
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
import { ParsedArgs , IEnvironmentService } from 'vs/platform/environment/common/environment' ;
import { createDecorator } from 'vs/platform/instantiation/common/instantiation' ;
import { ILogService } from 'vs/platform/log/common/log' ;
import { IURLSer
@lmcarreiro
lmcarreiro / core.ts
Last active March 19, 2018 15:06
Method declaration not column-indented
/**
* Filters an array by a predicate function. Returns the same array instance if the predicate is
* true for all elements, otherwise returns a new array instance containing the filtered subset.
*/
export function filter<T, U extends T>(array: T[], f: (x: T) => x is U): U[];
export function filter<T>(array: T[], f: (x: T) => boolean): T[];
export function filter<T, U extends T>(array: ReadonlyArray<T>, f: (x: T) => x is U): ReadonlyArray<U>;
export function filter<T, U extends T>(array: ReadonlyArray<T>, f: (x: T) => boolean): ReadonlyArray<T>;
export function filter<T>(array: T[], f: (x: T) => boolean): T[] {
if (array) {
@lmcarreiro
lmcarreiro / core.ts
Last active March 19, 2018 15:05
Method declaration column-indented
/**
* Filters an array by a predicate function. Returns the same array instance if the predicate is
* true for all elements, otherwise returns a new array instance containing the filtered subset.
*/
export function filter<T, U extends T>(array: T[], f: (x: T) => x is U ): U[];
export function filter<T >(array: T[], f: (x: T) => boolean): T[];
export function filter<T, U extends T>(array: ReadonlyArray<T> , f: (x: T) => x is U ): ReadonlyArray<U>;
export function filter<T, U extends T>(array: ReadonlyArray<T> , f: (x: T) => boolean): ReadonlyArray<T>;
export function filter<T >(array: T[], f: (x: T) => boolean): T[] {
if (array) {
@lmcarreiro
lmcarreiro / core.ts
Created March 19, 2018 15:04
Indented vs Not Indented
function Node(this: Node, kind: SyntaxKind, pos: number, end: number) {
this.pos = pos;
this.end = end;
this.kind = kind;
this.id = 0;
this.flags = NodeFlags.None;
this.modifierFlagsCache = ModifierFlags.None;
this.transformFlags = TransformFlags.None;
this.parent = undefined;
this.original = undefined;
@lmcarreiro
lmcarreiro / core.ts
Created March 30, 2018 02:23
filter function overload broken into multiple lines
export function filter<T, U extends T>(
array: T[],
f: (x: T) => x is U
) : U[];
export function filter<T>(
array: T[],
f: (x: T) => boolean
) : T[];
export function filter<T, U extends T>(
array: ReadonlyArray<T>,