Skip to content

Instantly share code, notes, and snippets.

@jepetko
jepetko / gist:26dfb75bdc5d961681895b9a73a351d2
Last active May 11, 2021 14:25
some_angular_localize_stuff
{
"contact-form--label-lastName": "Numele meu de familie este {$INTERPOLATION} :-)"
}
@jepetko
jepetko / get token for Graph API
Last active December 21, 2020 11:51
How to obtain access token for Graph API
import * as qs from 'querystring';
import 'isomorphic-fetch';
import {
AuthenticationHandler,
AuthenticationProviderOptions,
Client,
HTTPMessageHandler
} from '@microsoft/microsoft-graph-client';
export function getClient() {
@jepetko
jepetko / users.factory.ts
Created March 15, 2019 13:58
FeathersJS Authentication User Factory
import * as bcrypt from 'bcryptjs';
const hashPassword = (pwd) => {
const salt = bcrypt.genSaltSync(10);
return bcrypt.hashSync(pwd, salt);
};
export const DEFAULT_PASSWORD = 'pwd';
export function defineUserFactory(factory, model) {
@jepetko
jepetko / auth-beforeEach.ts
Created March 15, 2019 13:53
FeathersJS Authentication beforeEach
beforeEach(async () => {
const client: Sequelize.Sequelize = app.get('sequelizeClient');
const models = client.models as {[name: string]: Sequelize.Model<any, any>};
const UserModel = models.users as Sequelize.Model<User, UserAttrs>;
await UserModel.destroy({truncate: true});
setupUserRelatedFactory(UserModel);
});
@jepetko
jepetko / auth-test-skeletton.ts
Last active March 15, 2019 13:53
FeathersJS Authentication test skeletton
describe('POST /users', () => {
describe('for correct user/password data', () => {
let notifierSpy: sinon.SinonSpy;
let mailerStub: sinon.SinonStub;
beforeEach(() => {
notifierSpy = sinon.spy(Notifier, 'onNotify');
mailerStub = sinon.stub(app.service('mailer'), 'create');
describe('monkey test', () => {
let userInputs: any[] = [
{budget: 70, apple: 1, pear: 2, orange: 3},
{apple: 3, orange: 1},
{budget: 0}, // <<-- causes change detection exception
{pear: 10}
];
beforeEach(() => {
describe('change detection', () => {
let failure = 'There should be the exception: Expression has changed after it was checked';
let spy: any;
let myIt: any;
beforeEach(() => {
fixture.autoDetectChanges(true);
patchChangeDetection();
import {Component, OnInit} from 'angular2/core';
import {Tab} from './tab';
import {TabService} from './tab.service';
import {RouteParams} from 'angular2/router';
@Component({
selector: '[tabContent]',
template: `<div *ngIf="tab" class="panel panel-default">
<div class="panel-body">
<p class="active">{{tab.content}}</p>
@jepetko
jepetko / tabs.component.ts
Created March 21, 2016 20:37
Tabs component
import {Component, OnInit} from 'angular2/core';
import {Router, RouterOutlet} from 'angular2/router';
import {Tab} from './tab';
import {TabService} from './tab.service';
import {TabLinkComponent} from './tab-link.component';
import {TabContentComponent} from './tab-content.component';
import {TabFormComponent} from './tab-form.component';
@Component({
selector: 'tabs',