Skip to content

Instantly share code, notes, and snippets.

@rneto
rneto / isName.js
Last active November 12, 2015 11:36
Enter only names (numbers and special chars not allowed) in an input using javascript, regular expression and jquery
$(".isName").on("keypress keyup blur",function (event) {
var val = $(this).val();
if (val.match(/[@ºª*+\/\\|$#%()=?¿!¡¬^¨<>\[\]{}\-_&`'´".,:\;·€&#\d]+/)) {
$(this).val($(this).val().replace(/[@ºª*+\/\\|$#%()=?¿!¡¬^¨<>\[\]{}\-_&`'´".,:\;·€&#\d]+/, ""));
}
if ((event.which >= 48 && event.which <= 57)) {
event.preventDefault();
}
});
@rneto
rneto / iife.js
Last active May 21, 2021 04:26
Template literals test
(function() { var uno = '1'; console.log(`${uno}`);}).call()
// user/services/userService.ts
interface User {
userId: string;
email: string;
firstName: string;
lastName: string;
}
interface IUserService {
getUserByUserId (userId: string): Promise<User>;
import { TextUtil } from '../utils'
import { Result, Guard } from '../../core'
interface UserEmailProps {
email: string;
}
export class UserEmail extends ValueObject<UserEmailProps> {
// Private constructor. No one can say "new UserEmail('diddle')"
@rneto
rneto / vue-vuetify-vue-i18n-interface.d.ts
Created June 13, 2020 06:07
Merge Vuetify and VueI18n in a new Vue interface type for TypeScript
import { Vuetify, Framework } from 'vuetify/types';
import VueI18n, { IVueI18n } from 'vue-i18n/types';
declare module 'vue/types/vue' {
interface Vue {
$vuetify: Framework;
readonly $i18n: VueI18n & IVueI18n;
$t: typeof VueI18n.prototype.t;
$tc: typeof VueI18n.prototype.tc;
$te: typeof VueI18n.prototype.te;
@rneto
rneto / Result.cs
Last active August 17, 2021 14:18
using FluentValidation.Results;
namespace Application.Models
{
/// <summary>
/// Service result content.
/// </summary>
/// <typeparam name="T">Result data type.</typeparam>
public class Result<T>
{
using System.Text.Json;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace Presentation.Common
{
/// <summary>
/// Temp data extension class.
/// </summary>
public static class TempDataExtension
{
getCurrentScriptURLParam = (name: string) => {
const script = document.currentScript as HTMLScriptElement || document.querySelector('script[src*="script-name.js"]');
let value: string | null = '';
if (script?.src) {
const url = new URL(script?.src);
value = url.searchParams.get(name);
}
return value ?? '';
}
@rneto
rneto / auth.service.ts
Last active August 17, 2021 14:17
Authentication service preserving + (plus sign) in URLEncoded HTTP POST Request
// src/environments/environment.ts
//
// const url = 'http://localhost:12345/';
// export const environment = {
// authUrl: url + 'oauth/token',
// };
// ../utils/httpUrlEncodingCodec.ts
//
// import {HttpParameterCodec} from "@angular/common/http";
@rneto
rneto / util.ts
Last active October 31, 2022 07:12
Util TypeScript module for my Angular apps.
/**
* Make this a module.
*/
export {};
/**
* Access the global types
*/
declare global {
/**