Skip to content

Instantly share code, notes, and snippets.

export function emailExistsValidatorFn(userService: UserService, trueOnExists: boolean): AsyncValidatorFn {
console.log('validator triggered');
return (control: AbstractControl): Promise<ValidationErrors | null> | Observable<ValidationErrors | null> => {
console.log(userService);
return userService.checkIfEmailExists(control.value, trueOnExists).pipe(
take(1),
map((result: boolean) => {
console.log(result);
console.log('psovi nic');
return result ? null : {'emailexists': true};
@fr6nco
fr6nco / sock_http_reuse.js
Last active March 12, 2018 21:13
reuse nodejs socket for HTTP request
const net = require('net');
const http = require('http');
let client = new net.Socket();
let httpAgent = new http.Agent({keepAlive: true});
let sock = httpAgent.createConnection({port: 80, host:'localhost'}, (err, sock) => {
if(err) {
console.error(err);
}
@fr6nco
fr6nco / upgrade_ovs_in_mininet.sh
Created October 19, 2017 09:15 — forked from pichuang/upgrade_ovs_in_mininet.sh
Installing new version of Open vSwitch 2.3.0 use Mininet
#!/bin/sh -ev
# Reference: https://github.com/mininet/mininet/wiki/Installing-new-version-of-Open-vSwitch
# How to test: ovs-vsctl -V
# Check permission
test $(id -u) -ne 0 && echo "This script must be run as root" && exit 0
#Remove old version ovs
aptitude remove openvswitch-common openvswitch-datapath-dkms openvswitch-controller openvswitch-pki openvswitch-switch -y