Skip to content

Instantly share code, notes, and snippets.

@ljchuello
ljchuello / OnInit.sh
Last active November 19, 2023 17:47
OnInit.sh
#!/bin/bash
# Updates the packages
DEBIAN_FRONTEND=noninteractive apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
# Tools
apt install curl -y
apt install wget -y
apt install unzip -y
apt install nginx -y
@ljchuello
ljchuello / ini.sh
Created October 7, 2023 02:20
Con este script, actualizamos los paquetes, instalamos la ultima version .NET Core LTS, instalamos Python y Glances como servicio
#! /bin/bash
# Actualizamos
sudo apt update && sudo apt upgrade -y
# .NET Core
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS --install-dir /usr/share/dotnet
ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
# Python
apt install python3
apt install python3-dev -y
apt install python3-pip -y
@ljchuello
ljchuello / ntp.conf
Created September 28, 2023 01:52
ntp.conf
# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
driftfile /var/lib/ntp/ntp.drift
# Leap seconds definition provided by tzdata
leapfile /usr/share/zoneinfo/leap-seconds.list
# Enable this if you want statistics to be logged.
#statsdir /var/log/ntpstats/
@ljchuello
ljchuello / IntallNetCoreLinux.sh
Created September 21, 2023 14:12
With these simple commands we can install .NET Core in its most recent version of LTS in Ubuntu or Debian in any of its versions.
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel LTS --install-dir /usr/share/dotnet
ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
@ljchuello
ljchuello / ssh.net.cs
Created September 11, 2023 22:17
Método para conectarse desde C# a un terminal SSH en Linux utilizando llave privada
// Leemos la llave
string ssh = await File.ReadAllTextAsync(@"C:\UbicacionDeLaLlave\llave.ppk");
// Pasamos a MemoryStream
MemoryStream keyStream = new MemoryStream(Encoding.UTF8.GetBytes(ssh));
// Establecemos la conexión
ConnectionInfo connectionInfo = new ConnectionInfo("host", "Usuario | Suele ser root", new PrivateKeyAuthenticationMethod("root", new PrivateKeyFile(keyStream)));
// Entablamos la conexion
@ljchuello
ljchuello / netcore.sh
Last active August 3, 2023 02:51
Install the latest version of NET Core LTS on Linux operating systems
wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
chmod +x ./dotnet-install.sh
./dotnet-install.sh --channel LTS
export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$HOME/.dotnet:$HOME/.dotnet/tools
@ljchuello
ljchuello / get-networks.cs
Created December 22, 2022 13:26
Get networks
using System.Diagnostics;
using System.Net.NetworkInformation;
namespace Prueba
{
internal class Program
{
static void Main(string[] args)
{
@ljchuello
ljchuello / get-memory-netcore-linux.cs
Created December 22, 2022 12:42
Get Memory .NET Core Linux
using System.Diagnostics;
namespace Prueba
{
internal class Program
{
public class MemoryMetrics
{
public double Total;
public double Used;
@ljchuello
ljchuello / CallLambda.cs
Created June 22, 2022 00:54
Ejecuta una función de AWS Lambda desde C#
// Parametro
string parametro = "ljchuello";
// CLiente
AmazonLambdaClient lambdaClient = new AmazonLambdaClient("AccesKey", "SecretKey", RegionEndpoint.USEast1);
// Contecto
InvokeRequest invokeRequest = new InvokeRequest
{
FunctionName = "Test_Lambda",
@ljchuello
ljchuello / cartav2.txt
Last active August 28, 2021 19:33
Ejemplo de envío de carta dinagráfica
curl --location --request POST 'https://dpsos.entecprois.com/api/v1/cartadinagrafica/' \
--header 'Content-Type: application/json' \
--data-raw '{
"CartaDinagrafica": {
"SurfaceCardPosition": [
0.091543,
0.271862,
0.578872,
0.90781,
1.236326,