Skip to content

Instantly share code, notes, and snippets.

View Orbis25's full-sized avatar
🚀
Working

Orbis Alonzo Gutierrez Orbis25

🚀
Working
View GitHub Profile
@Orbis25
Orbis25 / web.config
Last active November 20, 2019 02:23
web.config this code is necesary when you deploy app in reactjs in (IIS) , Check if working for (Vuejs and Angularjs) this file is necesary inclounding in public folder
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="React Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
@Orbis25
Orbis25 / main.js
Last active December 5, 2019 19:47
Text to spech example usin api from javaScript (speaknowjs)
const synth = window.speechSynthesis;
const readText = (
text = "FELICIDADES"
) => {
voices = synth.getVoices();
event.preventDefault();
let utterThis = new SpeechSynthesisUtterance(text);
var selectedOption = "Google español de Estados Unidos";
for (i = 0; i < voices.length; i++) {
@Orbis25
Orbis25 / index.html
Created December 5, 2019 19:46
Simple animation in button pulse
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.11.2/css/all.css"
/>
@Orbis25
Orbis25 / EnumExtension.cs
Created December 9, 2019 23:35
Simple extension in c# for get the displayName atribute in enums
public static class EnumExtension
{
public static string GetAttribute(this Enum enumValue)
=> enumValue.GetType()?.GetMember(enumValue.ToString())?.FirstOrDefault()?.GetCustomAttribute<DisplayAttribute>(false)?.Name ?? enumValue.ToString();
}
@Orbis25
Orbis25 / IRepository.ts
Created August 26, 2020 19:38
Simple Repository Pattern in TypeScript with axios
import { AxiosResponse } from "axios";
import { AxiosConfig } from "../../api";
export interface IRead<T> {
getAll(route: string, params?: string): Promise<AxiosResponse<T[]>>;
getById(route: string, id: string): Promise<AxiosResponse<T>>;
getPaginatedList(route: string, params?: string): Promise<AxiosResponse<T[]>>;
}
export interface IWrite<T> {
@Orbis25
Orbis25 / .babelrc
Last active January 12, 2021 01:44
server side rendering in reactjs with typescript
{
"plugins": [
"@babel/plugin-proposal-class-properties",
"@babel/plugin-syntax-dynamic-import",
"@babel/plugin-proposal-optional-chaining",
"@babel/plugin-proposal-nullish-coalescing-operator"
],
"presets": ["@babel/preset-react"]
}
@Orbis25
Orbis25 / package.json
Created March 30, 2021 13:25
heroku deploy app nodejs and ts
"scripts":{
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "SET NODE_ENV=development &&nodemon index.ts",
"start": "node index.js",
"build": "tsc",
"postinstall": "npm run build"
}
@Orbis25
Orbis25 / extension.cs
Created April 15, 2021 19:42
get dbcontext instance in middleware
//IApplicationBuilder app;
using var appScoped = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>().CreateScope();
ApplicationDbContext _context = appScoped.ServiceProvider.GetService<ApplicationDbContext>();
UserManager<ApplicationUser> _userManager = appScoped.ServiceProvider.GetService<UserManager<ApplicationUser>>();
@Orbis25
Orbis25 / index.js
Created April 26, 2021 18:46
Convert html form to json.
/**
* Convert form to json
* @param {Event} event evento del formulario
*/
const FormToJson = async (event) => {
event.preventDefault();
const data = new FormData(event.target)
const values = Object.fromEntries(data.entries());
return values
}
@Orbis25
Orbis25 / PaginationPartialModel.cs
Created May 5, 2021 18:24
Paginacion para las vistas parciales
public class PaginationPartialModel
{
public int ActualPage { get; set; }
public int Total { get; set; }
public int Qyt { get; set; }
public bool RenderOneInFirstPage { get; set; }
public string Url { get; set; }
public string IdToLoad { get; set; }
}