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
const schema = { | |
id: { | |
type: 'int UNSIGNED', | |
value: 'AUTO_INCREMENT', | |
key: 'PRIMARY KEY' | |
}, | |
title: { | |
type: 'VARCHAR(255)', | |
value: 'NOT NULL' | |
}, |
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
const tsconfig = require('./tsconfig.json'); | |
const path = require('path'); | |
const fs = require('fs'); | |
(function () { | |
const sliceAsterisk = (url) => url.split('/*')[0]; | |
const getFilePath = (url) => { | |
const urlParts = url.split('/'); | |
urlParts.splice(0, 1); | |
return urlParts.join('/'); |
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
const fs = require('fs'); | |
const path = require('path'); | |
const Client = require('ftp'); | |
const program = require('commander'); | |
const client = new Client(); | |
client.connect({ | |
user: "", | |
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
import 'dart:mirrors'; | |
class Person { | |
String firstname; | |
String lastname; | |
} | |
main() { | |
final json = {"firstname": "ezz", "lastname": "abuzaid"}; | |
Person person = deserialize(json, Person); |
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
class EventEmitter { | |
constructor() { | |
this.callbacks = {}; | |
this.noEventYet = []; | |
} | |
addEventListener(eventName, callback) { | |
const callbacks = this.callbacks[eventName]; |
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 compute(computation, ...message) { | |
const delegate = () => { | |
onmessage = ({ data: { computation, message } }) => { | |
const wrapper = (fn) => Function('"use strict"; return (' + fn.toString() + ')')(); | |
const result = wrapper(computation)(...message); | |
postMessage(result); | |
}; | |
} | |
const functionBody = delegate.toString().replace(/^[^{]*{\s*/, '').replace(/\s*}[^}]*$/, ''); | |
return new Promise((resolve, reject) => { |
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
/** | |
* | |
* Wrap database calls within transaction | |
* | |
* @param computation an action function with {EntityManager} argument that will be executed after starting the transaction | |
* | |
*/ | |
export async function useTransaction<TResult>(computation: (manager: EntityManager) => Promise<TResult>) { | |
let queryRunner = getConnection().createQueryRunner(); |
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 { Pipe, PipeTransform } from '@angular/core'; | |
@Pipe({ | |
name: 'singularize' | |
}) | |
export class SingularizePipe implements PipeTransform { | |
public transform(value: any, count: number = 1): string { | |
return count > 1 ? plural(value) : singular(value); |
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
const tsConfig = require('../tsconfig.json'); | |
const tsConfigPaths = require('tsconfig-paths'); | |
tsConfigPaths.register({ | |
baseUrl: __dirname, | |
paths: tsConfig.compilerOptions.paths, | |
}); |
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 { ComponentType } from '@angular/cdk/portal'; | |
import { TestbedHarnessEnvironment } from '@angular/cdk/testing/testbed'; | |
import { DebugElement, InjectionToken } from '@angular/core'; | |
import { ComponentFixture, TestBed, TestModuleMetadata } from '@angular/core/testing'; | |
import { By } from '@angular/platform-browser'; | |
import { Subject } from 'rxjs'; | |
export class Page<T> { | |
private _fixture: ComponentFixture<T>; | |
constructor( |
OlderNewer