Goland CORS, logs and healtcheck

In this guide, weโ€™ll walk through how to create CORS (Cross-Origin Resource Sharing) and a health check endpoint in a Golang application using the Chi router. Setting Up Chi and CORS Middleware Weโ€™ll use the go-chi/chi and go-chi/cors packages to handle routing and CORS in our application. Step 1: Import Required Packages First, make sure to import the necessary packages: import ( "fmt" "net/http" "log" "github.com/go-chi/chi" "github.com/go-chi/chi/middleware" "github.com/go-chi/cors" AdminMiddleware "github.com/project/api/middleware" "github.com/project/api/services" "gorm.io/gorm" ) Step 2: Define the CORS AllowOriginFunc Weโ€™ll define a function to specify the allowed origins for CORS. This function also logs disallowed origins: ...

2024-06-01 ยท map[name:Jose Castrillo]

Python & Virtual Environments

When starting a Python 3 project in Linux, itโ€™s essential to follow best practices to ensure a clean and isolated development environment. One of the recommended approaches is to utilize virtual environments. Virtual environments allow you to create an isolated environment for each project, preventing conflicts between different packages and dependencies. In this guide, weโ€™ll walk you through the steps to set up and activate a virtual environment for your Python 3 project. ...

2023-03-15 ยท map[name:Jose Castrillo]

Java Native Memory Tracking in GNU/linux

Java provides a Native Memory Tracking feature that enables you to monitor the memory usage of your Java application. This feature is particularly useful for identifying memory leaks and optimizing the memory usage of your application. In this post, we will discuss how to activate Native Memory Tracking for a Java jar application in Linux. Step 1: Check Java Version First, you need to check the version of Java installed on your system using the following command: ...

2023-01-10 ยท map[name:Jose Castrillo]

HelloWorld Solidity

Thisโ€™s my Hello World on Solidity: // SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.6 < 0.9.0; contract TaskContract { uint nextId; struct Task { uint id; string name; string description; } Task[] tasks; function createTask (string memory _name, string memory _description) public { tasks.push(Task(nextId, _name, _description)); nextId++; } function findIndex(uint _id) internal view returns (uint) { for (uint i=0;i < tasks.length; i++){ if (tasks[i].id == _id){ return i; } } revert('Task not found'); } function readTask(uint _id) public view returns (uint, string memory, string memory) { // _id ---> variable local uint index = findIndex(_id); return (tasks[index].id, tasks[index].name, tasks[index].description); } function updateTask(uint _id, string memory _name, string memory _description) public { uint index = findIndex(_id); tasks[index].name = _name; tasks[index].description = _description; } function deleteTask(uint _id) public{ uint index =findIndex(_id); delete tasks[index]; } } Tutorial followed: Solidity SCRUD

Parsing date format from .xlsx to R

Version: platform x86_64-redhat-linux-gnu arch x86_64 os linux-gnu system x86_64, linux-gnu version.string R version 3.5.3 (2019-03-11) Library lubridate Parse method โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” as.factor โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” mydata$FECHA_NACIMIENTO<-as.factor(mydata$FECHA_NACIMIENTO) โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” variable for strptime โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” tempo<-strptime(mydata$FECHA_NACIMIENTO,"%d/%m/%Y") mydata$FECHA_NACIMIENTO<-as.Date(tempo,"%d/%m/%Y") โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” clean variable โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” rm (tempo) mydata$FECHA_NACIMIENTO <- format(as.Date(mydata$FECHA_NACIMIENTO), "%d/%m/%Y") โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” parsing data โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€”โ€” library(lubridate) mydata$FECHA_NACIMIENTO <-dmy(mydata$FECHA_NACIMIENTO)

2019-04-01 ยท map[name:Jose Castrillo]