Skip to content

Instantly share code, notes, and snippets.

View amagno's full-sized avatar
🏠
Working from home

Alexandre Magno Monteiro amagno

🏠
Working from home
View GitHub Profile
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using AutoMapper;
using AutoMapper.Internal;
namespace Agenda.Application.Extensions
{
public static class AutoMapperExtensions
using System;
using System.Security.Cryptography;
namespace Infra
{
public class PasswordHasher
{
///
/// Return a string delimited with random salt, #iterations and hashed password
EXEC sp_MSForEachTable 'DISABLE TRIGGER ALL ON ?'
EXEC sp_MSForEachTable 'ALTER TABLE ? NOCHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable 'SET QUOTED_IDENTIFIER ON; IF OBJECT_ID(''?'') NOT IN (ISNULL(OBJECT_ID(''[dbo].[__EFMigrationsHistory]''),0)) DELETE FROM ?'
EXEC sp_MSForEachTable 'ALTER TABLE ? CHECK CONSTRAINT ALL'
EXEC sp_MSForEachTable 'ENABLE TRIGGER ALL ON ?'
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.AspNetCore.TestHost;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
public class Test
{
private MailMessage TransformarImageBase64EmAnexo(MailMessage mailMessage)
{
string body = mailMessage.Body;
var reg = new Regex("src=\"(data:image\\/[^;]+;base64[^\"]+)\"");
var matches = reg.Matches(body);
//var split = new Regex("src=\"").Split(match.Value).Where(s => !string.IsNullOrEmpty(s)).ToList();
foreach (Match match in matches)
@amagno
amagno / DataTable.jsx
Created August 21, 2019 01:38
DataTable react-bootstrap
import React from 'react';
import { Table, Form, Button, Col, Row, Spinner, Fade, Dropdown, DropdownButton, Pagination } from 'react-bootstrap';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faSearch, faPlusSquare, faSort, faSortUp, faSortDown, faTimes } from '@fortawesome/free-solid-svg-icons';
import { Link } from 'react-router-dom';
import { orderBy, chunk } from 'lodash';
const buildStringSearchRegex = (str) => {
const strArray = Array.from(str);
const regexArray = strArray.map(word => {
import { v4 } from 'uuid';
import * as arrayToTree from 'array-to-tree';
type Tranformer<TItem, TResult> = (item: TItem, level?: number) => TResult;
export interface DataNode {
UUID?: string;
parentUUID?: string;
children?: any[];
protected void ToSnakeCase(ModelBuilder builder)
{
base.OnModelCreating(builder);
foreach (var entity in builder.Model.GetEntityTypes())
{
// Replace table names
entity.Relational().TableName = entity.Relational().TableName.ToSnakeCase();
// Replace column names
const http = require('http');
const port = 3000;
const ip = 'localhost';
const server = http.createServer((req, res) => {
let data = '';
req.on('data', chunk => {
data += chunk;
});
@amagno
amagno / util.ts
Created February 20, 2019 13:04
stringRegex
export const buildStringSearchRegex = (str: string): RegExp => {
const strArray = Array.from(str);
const regexArray = strArray.map(word => {
if (word === 'a') { return '[à-úÀ-ÚaA]'; }
if (word === 'e') { return '[à-úÀ-ÚeE]'; }
if (word === 'i') { return '[à-úÀ-ÚiI]'; }
if (word === 'o') { return '[à-úÀ-ÚoO]'; }
if (word === 'u') { return '[à-úÀ-ÚuU]'; }
return word;
});