Skip to content

Instantly share code, notes, and snippets.

View Streeterxs's full-sized avatar
🍉
Chill & code

Afonso Araújo Neto Streeterxs

🍉
Chill & code
View GitHub Profile
import { graphql } from 'react-relay';
import { getNode } from 'relay-runtime';
const ShoesListQuery = graphql`
query ShoesListQuery {
shoes {
size
type
}
}
const readline = require('readline');
const childProcess = require('child_process');
const readlineInterface = readline.createInterface({
input: process.stdin,
output: process.stdout
});
readlineInterface.question(`Digite o nome do projeto que queira abrir: \n`, (input) => {
const path = require('path');
const {spawn} = require('child_process');
(() => {
const mongod = spawn('mongod', [], {cwd: 'c:/Program Files/MongoDB/Server/4.2/bin'});
mongod.stdout.on('data', (data) => {
console.log(`${data}`);
});
})()
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'filterNgxMultiselect'
})
export class FilterNgxMultiselectPipe implements PipeTransform {
transform(arrayNgxMultiselect: {key: string, value: string | number}[], stringToFilter: string): any {
return !!arrayNgxMultiselect ?
arrayNgxMultiselect.filter(item => `${item.value}`.toLowerCase().trim().includes(stringToFilter.toLowerCase().trim()) || item.key.toLowerCase().trim().includes(stringToFilter.toLowerCase().trim())) :
const [formValidation, setFormValidation] = useState<UserFormValidation>({
emailIsValid: false,
cpfIsValid: false,
nomeIsValid: false,
cepIsValid: false,
ruaIsValid: false,
numeroIsValid: false,
bairroIsValid: false,
cidadeIsValid: false,
showErrors: false
import AsyncStorage from "@react-native-community/async-storage";
const asyncStorage = <T,>(key: string) => {
const getValue = async (): Promise<T | null> => {
const value = await AsyncStorage.getItem(key);
return value ? JSON.parse(value) : null;
};
import { asyncStorageModule } from "../asyncStorage";
import { getUniqueId } from "react-native-device-info";
class Device {
private _device: string = '';
private _isFetching = false;
private static _instance: Device;
private _deviceAsyncStorageModule = asyncStorageModule<string>('device');
private constructor() {}
import { RequestParameters } from 'relay-runtime/lib/util/RelayConcreteNode';
import { Variables, Disposable } from 'relay-runtime/lib/util/RelayRuntimeTypes';
import { SubscriptionClient, Observer } from 'subscriptions-transport-ws';
import config from '../config';
import { ExecutionResult } from 'graphql';
import { Observable, SubscribeFunction, Subscribable, GraphQLResponse } from 'relay-runtime';
import { RelayObservable } from 'relay-runtime/lib/network/RelayObservable';
export function getToken(): string {
@Streeterxs
Streeterxs / passwordMatchValidation.ts
Last active December 27, 2019 14:28
This function make a validation and setErrors to the form, without the need of creating a StateMatcher to setErrors
import { AbstractControl } from "@angular/forms";
export function passwordMatchValidator(control: AbstractControl): {[key: string]: boolean} | null {
const password = control.get('password');
const passwordRepeat = control.get('passwordRepeat');
const passwordErrors = { ...password.errors };
const passwordRepeatErrors = { ...passwordRepeat.errors };
if (password.value !== passwordRepeat.value) {
password.setErrors({passwordMatchValidator: true});
passwordRepeat.setErrors({passwordMatchValidator: true});
/// <reference lib="webworker" />
addEventListener('message', ({ data }) => {
const response = `worker response to ${data.lista}`;
const objMessageReturn = {
value: data.lista[0],
halfDown: null,
halfUp: null
};
if (data.lista.length > 1) {