Skip to content

Instantly share code, notes, and snippets.

View xantiagoma's full-sized avatar

Santiago Montoya A. xantiagoma

View GitHub Profile
/^((\+|\+\(|\(\+)?[0-9]+\)?)?([0-9]+| |-|\.)+(((extension|ext|ext\.|extension\.|ex|ex\.|e|e\.)? ?)[0-9]+)?$/igm
^((\+|\+\(|\(\+)?[0-9]+\)?)?([0-9]+| |-|\.)+(((extension|ext|ext\.|extension\.|ex|ex\.|e|e\.)? ?)[0-9]+)?$
@echo off
::
:: RefreshEnv.cmd
::
:: Batch file to read environment variables from registry and
:: set session variables to these values.
::
:: With this batch file, there should be no need to reload command
:: environment every time you want environment changes to propagate
@xantiagoma
xantiagoma / command.sh
Created May 2, 2018 14:24
Open mac app from unidentified developer
xattr -cr /Applications/<app>.app
(async () => {
const { ajax: ajaxp, operators, from } = rxjs;
const { ajax } = ajaxp;
const { getJSON } = ajax;
const { map, flatMap, toArray } = operators;
const promise =
getJSON(
"https://pokeapi.co/api/v2/pokemon/"
)
.pipe(
@xantiagoma
xantiagoma / ngGetWrongFormControls.js
Last active December 13, 2018 18:52
While debug copy & paste functions
// Select <gh-event> in Elements panel then in
// Console paste:
var eventForm = ng.probe($0).componentInstance.eventForm;
var FormArray = eventForm.constructor;
var FormGroup = eventForm.controls[0].constructor;
var findInvalidControlsRecursive = function findInvalidControlsRecursive(formToInvestigate) {
var invalidControls = [];
var recursiveFunc = function (form) {
Object.keys(form.controls).forEach(function (field) {
var control = form.get(field);
@xantiagoma
xantiagoma / main.dart
Last active November 10, 2018 21:44
Hello World Flutter / Dart
import 'package:flutter/cupertino.dart'; // importa todas las funciones sin prefix
// import 'package:flutter/cupertino.dart' as cupertino; // go-style use cupertino.runApp(...
void main(){
runApp(
Center(
child: Text(
'Hello World',
), // Text
)
public only($event: KeyboardEvent) {
console.log("press");
let regex: RegExp = new RegExp(/^[0-9a-zA-Z]{1,}$/g);
let specialKeys: Array<string> = ['Backspace', 'Tab', 'End', 'Home', 'ArrowRight','ArrowLeft'];
if (specialKeys.indexOf($event.key) !== -1) {
return;
} else {
if (regex.test($event.key)) {
return true;
} else {
onEdit($event: Event) {
if( $event instanceof KeyboardEvent ) {
let key = ($event.keyCode || $event.charCode);
let maxLength = ($event.target as HTMLInputElement).maxLength;
let valueLength = ($event.target as HTMLInputElement).value.length;
if(maxLength === valueLength) {
let index = this.inputs.map(e => e.nativeElement)
.findIndex(e => e === $event.target);
let next = (index + 1) > (this.inputs.length - 1) ? (this.inputs.length - 1) : (index + 1);
(this.inputs[next].nativeElement as HTMLInputElement).focus();
@xantiagoma
xantiagoma / file.dart
Created December 15, 2018 03:34
Dart Example Parse/Decode JSON Nested Classes
import 'package:dart_date/dart_date.dart';
import 'dart:convert';
class LastActivities {
Date all;
MoviesActivities movies;
EpisodesActivities episodes;
ShowsActivities shows;
SeasonsActivities seasons;
CommentsActivities comments;
ListsActivities lists;
@xantiagoma
xantiagoma / ngDeleteOverlayInTest.module.ts
Last active January 15, 2019 14:39
DialogTestModule
import { NgModule } from '@angular/core';
import { MatDialogModule } from '@angular/material';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { OverlayContainer } from '@angular/cdk/overlay';
export const TEST_DIRECTIVES = [
Components, Pipes
];
@NgModule({