Skip to content

Instantly share code, notes, and snippets.

View AD0791's full-sized avatar
🎯
Focusing

Alexandro Disla AD0791

🎯
Focusing
  • Haiti
  • 07:50 (UTC -12:00)
View GitHub Profile
@AD0791
AD0791 / server2.js
Last active June 14, 2020 21:40
nodejs server with request event listener
// npm init
// npm i http -S
// npm i http-status-codes -S
const port = 9000;
http = require('http');
httpStatus = require('http-status-codes');
app = http.createServer();
@AD0791
AD0791 / gist:4d8633a241fc54bd84a5af050a0f9d03
Created August 20, 2020 19:36
RestServices express with Static json file (joi for validation)
const express = require("express");
const app = express();
const data = require("./mock.json");
const Joi = require("joi");
// middleware
app.use(express.json());
// get
app.get("/api", (req, res) => {
res.send(data.api);
@AD0791
AD0791 / basics.MD
Last active October 17, 2020 19:38
python for developpers notes 2

Python-Dev


We have set up the learning path and the most particular features of python.

We are looking for efficiency and a quick glossary-type to retrieve and process the task or information.

dir(class_ name or module_name)
@AD0791
AD0791 / Standard.md
Last active October 17, 2020 19:40
python for developers notes 2

Python programming for developpers


We are moving from the Basic.md

import Basic
@AD0791
AD0791 / Rmd
Created February 12, 2021 03:01
Some Rmarkdown tricks to produce Latex files
---
title: ""
author: ""
date: "DD/MM/YYYY"
header-includes: |
\usepackage{mathtools, amssymb , amsthm, amsfonts}
output:
pdf_document:
keep_tex: yes
latex_engine: xelatex
@AD0791
AD0791 / sh
Last active July 23, 2021 19:08
RUN AS ADMINISTRATOR powersehll
Start-Process powershell -Verb runAs
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted
@AD0791
AD0791 / sqrt.go
Created July 25, 2021 15:06
SQRT implementation
package main
import (
"fmt"
"math"
)
func Sqrt(x float64) float64 {
z := float64(1)
for i := 1; i <= 10; i++ {
@AD0791
AD0791 / swagger_express.js
Last active August 17, 2021 20:09
simple swagger usage with express
const express = require("express");
const app = express();
const swaggerJsDoc = require("swagger-jsdoc");
const swaggerUi = require("swagger-ui-express");
const port = process.env.PORT || 5000;
// Extended: https://swagger.io/specification/#infoObject
const swaggerOptions = {
swaggerDefinition: {
@AD0791
AD0791 / redux.js
Last active September 20, 2021 02:19
redux
const INCREMENT = "INCREMENT"; // define a constant for increment action types
const DECREMENT = "DECREMENT"; // define a constant for decrement action types
// define the counter reducer which will increment or decrement the state based on the action it receives
const counterReducer = (state = 0, action) => {
switch (action.type) {
case INCREMENT:
return state + 1;
case DECREMENT:
@AD0791
AD0791 / Middleware.js
Created September 25, 2021 22:09
Redux simplification
/*
Middlewares provide us with the ability to intercept actions and do something we want to before that action reaches the reducers. We can log actions, log store state, log crash reports, etc.
Let's create a middleware for logging actions when they get dispatched.
*/
const logger = (store) => (next) => (action) => {
console.log("DISPATCHED ACTION: ", action);
next(action);
}