Skip to content

Instantly share code, notes, and snippets.

View alefra88's full-sized avatar
💻

Alan.dev alefra88

💻
View GitHub Profile
@alefra88
alefra88 / spInsertarUsuario.sql
Last active November 5, 2024 21:54
sp en sql server para insertar usuario con password hasheada, se agregó mensaje de error
USE [DB_desde_transact]
GO
/****** Object: StoredProcedure [dbo].[spUsuariosInsertar] Script Date: 05/11/2024 03:52:16 p. m. ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[spUsuariosInsertar]
(
@Email varchar(250),
@alefra88
alefra88 / constructor.cs
Created July 30, 2024 17:49
Constructor que recibe cadena de conexión desde appsettings.json y que usa el objeto ConfigurationBuilder
//En el método constructor se cargará la URL de la web api que se especifico en appsettings.json
//para esto se utiliza un objeto ConfigurationBuilder
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
_urlWebAPI = builder.GetSection("urlWebAPI").Value;
public class BLAlumnos
{
private string _urlWebAPI;
public BLAlumnos() { }
public async Task<List<Alumnos>> Consultar() { }
public async Task<Alumnos> Consultar(int? id) { }
public async Task<Alumnos> Agregar(Alumnos alumnos) { }
public async Task Actualizar(Alumnos alumnos) { }
public async Task Eliminar(int id) { }
}
@alefra88
alefra88 / program.cs
Created July 30, 2024 16:30
builder service into Program MVC core
// Add services to the container.
builder.Services.AddDbContext<NameContext>(options =>
options.UseSqlServer(builder.Configuration.GetConnectionString("DBConnectionName")));
// Add Authorization services
builder.Services.AddAuthorization();
Scaffold-DbContext "Server=LAPTOP-S8HOTDC5\SQLEXPRESS;Database=DBName;User ID=sa; password=password;" Microsoft.EntityFrameWorkCore.SqlServer -Tables TableName -Context NameContext -ContextDir Models/Context -OutputDir Models/Entities -NoPluralize -Force
@alefra88
alefra88 / managerClick.js
Created July 14, 2024 01:18
Proteger de multiples clicks
function eventManager(){
let executing = false;
return async ()=>{
if(!executing){
executing = true;
await fn();
setTimeout(()=>{executing = false},2000);
}
}
}
@alefra88
alefra88 / app.js
Created March 12, 2023 10:36
142. WordPress REST API y Fetch
const d = document,
$site = d.getElementById("site"),
$posts = d.getElementById("posts"),
$loader = d.querySelector(".loader"),
$template = d.getElementById("post-template"),
$fragment = d.createDocumentFragment(),
DOMAIN = "https://malvestida.com",
SITE = `${DOMAIN}/wp-json`,
API_WP = `${SITE}/wp/v2`,
POSTS = `${API_WP}/posts?_embed`,
@alefra88
alefra88 / app.js
Last active September 2, 2024 01:22
Codigo js de la clase 141 wordpress API rest fetch
const d = document,
$site = d.getElementById("site"),
$posts = d.getElementById("posts"),
$loader = d.querySelector(".loader"),
$template = d.getElementById("post-template"),
$fragment = d.createDocumentFragment(),
DOMAIN = "https://malvestida.com",
SITE = `${DOMAIN}/wp-json`,
API_WP = `${SITE}/wp/v2`,
POSTS = `${API_WP}/posts?_embed`,
@alefra88
alefra88 / app.js
Last active March 11, 2023 12:15
consumo de api wordpress con POO JS
// const d = document,
// $site = d.getElementById("site"),
// $posts = d.getElementById("posts"),
// $loader = d.querySelector(".loader"),
// $template = d.getElementById("post-template"),
// $fragment = d.createDocumentFragment(),
// DOMAIN = "https://malvestida.com",
// SITE = `${DOMAIN}/wp-json`,
// API_WP = `${SITE}/wp/v2`,
// POSTS = `${API_WP}/posts`,
@alefra88
alefra88 / app.js
Last active March 9, 2023 10:46
APIs: Buscador de Shows con Fetch y TVMAZE API
const d = document,
$shows = d.getElementById("shows"),
$template = d.getElementById("show-template"),
$fragment = d.createDocumentFragment();
d.addEventListener("keypress", async (e) => {
if (e.target.matches("#search")) {
// console.log(e.key, e.keyCode);
if (e.key === "Enter") {
try {