jueves, 31 de marzo de 2022

Como hacer tu propia biblioteca de funciones en C#

 

Si queremos hacer nuestra propia biblioteca de funciones para poder reutilizar funciones en diferentes proyectos, básicamente, seria crear nuestro propio DDL.

Crearemos un proyecto normal con Visual Studio, llamarlo como queráis.

Creamos una clase llamada Funciones y meteremos lo siguiente:

1
2
3
4
5
6
7
8
9
10
11
12
public static int suma(int a, int b)
{
    return a + b;
}
 
public static void mostrarArray(int[] array)
{
    for (int i=0; i<array.Length ;i++)
    {
        Console.WriteLine(array[i]);
    }
}

Una vez que lo tengas, simplemente, debemos compilar nuestra biblioteca.

Si todo se hizo bien, se debería crear el .ddl en la carpeta bin/Debug del proyecto.

Con eso estaría nuestra biblioteca, ahora crearemos otro proyecto y en Proyecto -> Agregar referencia…

Y en Examinar elegimos la ruta donde tengamos el ddl creado.

En el fichero Program.cs, poner lo siguiente:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BibliotecaDDR;
 
namespace test_biblioteca
{
    class Program
    {
        static void Main(string[] args)
        {
 
            Console.WriteLine(Funciones.suma(5, 6));
 
            int[] valores = { 1, 2, 3, 4, 5 };
 
            Funciones.mostrarArray(valores);
 
            Console.ReadLine();
        }
    }
}

Fijaros que debemos usar esta linea using BibliotecaDDR;

Este es el resultado:

 

https://www.discoduroderoer.es/como-hacer-tu-propia-biblioteca-de-funciones-en-c-sharp/

miércoles, 23 de marzo de 2022

linux find and mv 20000 *.pdf

#move only 20000 | no sort

find ~/PDF/FOLDER_1 "*.pdf" -type f | head -20000 |xargs mv -t ~/PDF/FOLDER_5

jueves, 17 de marzo de 2022

Package Creation Chocolatey

 

Quick Start

Creating Chocolatey Packages - TL;DR version

Here's a TL;DR quick start version of the package creating tutorial. Follow these steps to create a simple package.

Problem? Read the detailed version: Creating Chocolatey Packages

Prerequisites

  • You have Chocolatey installed.
  • You've read What are Chocolatey Packages? first.
  • You know how a package works
    • A package contains a nuspec file. This defines the package. (Docs)
    • A package may contain embedded software.
    • A package may contain an installation script. This can be very simple.

Quick start guide

  • Generate new package:
    • choco new -h will get you started seeing options available to you.
    • Once you figured out all of your options, you should move forward with generating your template.
  • Edit template using common sense
    • cd package-name
    • Edit the package-name.nuspec configuration file.
    • Edit the ./tools/chocolateyInstall.ps1 install script.
    • You must save your files with UTF-8 character encoding without BOM. (Details)
  • Build the package
    • Still in package directory
    • choco pack
      • "Successfully created package-name.1.1.0.nupkg"
  • Test the package
    • Testing should probably be done on a Virtual Machine
    • In your package directory, use:
      • choco install package-name -s . (package-name is the id element in the nuspec)
  • Push the package to the Chocolatey community package repository:
    • Get a Chocolatey account:
    • Copy the API key from your Chocolatey account.
    • choco apikey -k [API_KEY_HERE] -source https://push.chocolatey.org/
    • choco push package-name.1.1.0.nupkg -s https://push.chocolatey.org/ - nupkg file can be ommitted if it is the only one in the directory.

Common Mistakes

  • NuSpec
    • id is the package name and should meet the following criteria:
      • should contain no spaces and weird characters.
      • should be lowercase.
      • should separate spaces in the software name with - e.g. classic-shell. Yes, we realize there are a lot of older packages not following this convention.
    • version is a dot-separated identifier containing a maximum of 4 numbers. e.g. 1.0 or 2.4.0.16 - except for prerelease packages

Environmental Variables

  • %ChocolateyInstall% - Chocolatey installation directory
  • %ChocolateyInstall%\lib\package-name - Package directory
  • %cd% or $pwd - current directory
  • Environment variable reference available in the README when using choco new or online.

Examples

Here are some simple examples.

📝 NOTE This needs updated with checksums and newer package concepts. Please run choco new when creating packages as it contains all of the most up to date notes.

chocolateyInstall.ps1 for .exe installer

$name = 'Package Name'
$installerType = 'exe'
$url  = 'http://path/to/download/installer.exe'
$silentArgs = '/VERYSILENT'

Install-ChocolateyPackage $name $installerType $silentArgs $url

📝 NOTE You have to figure out the command line switch to make the installer silent, e.g. /VERYSILENT. This changes from installer to installer.

chocolateyInstall.ps1 for .msi installer

📝 NOTE Please maintain compatibility with Posh v2. Not every OS we support is on Posh v2 (nor comes OOB with Posh v3+). It's best to work with the widest compatibility of systems out there.

$packageName = 'Package Name'
$installerType = 'msi'
$url = 'http://path/to/download/installer_x86.msi'
$url64 = 'http://path/to/download/installer_x64.msi'
$silentArgs = '/quiet'
$validExitCodes = @(0,3010)

Install-ChocolateyPackage $packageName $installerType $silentArgs $url $url64  -validExitCodes $validExitCodes

Parsing Package Parameters

For a complete example of how you can use the PackageParameters argument of the choco install command, see this How-To.

Tips

 

https://docs.chocolatey.org/en-us/create/create-packages-quick-start

lunes, 7 de marzo de 2022

How to Compare Two Files in Notepad++

 


How to Compare Two Files in Notepad++

The compare plugin assumes that you want to compare an old version of your work versus the new version. Open any two files (A, B) in Notepad++, which you want to compare. File B (new) gets compared to File A (old).

Then, navigate to Plugins > Compare Menu > Compare.

It shows the difference/comparison side by side, as shown in the screenshot. You can set any open file as the default. Simply click Compare > Set as First to Compare. Choose this selected file to compare it with other ones in whatever mode you decide.

 

https://www.makeuseof.com/tag/notepad-compare-two-files-plugin/#:~:text=Open%20any%20two%20files%20(A,as%20shown%20in%20the%20screenshot.