Стрілкові функції в JavaScript

Стрілкові функції в JavaScript – це не просто скорочений синтаксис, а справжні магічні стріли, які можуть зробити ваш код більш читабельним та зручним. Ось декілька цікавих речей, які ви можете робити з ними:

Короткі функції з одним виразом: Стрілкові функції ідеально підходять для коротких функцій, які повертають один результат. Наприклад:

    const numbers = [1, 2, 3, 4, 5];
    const squared = numbers.map((num) => num ** 2);
    console.log(squared); // Виведе [1, 4, 9, 16, 25]

    Callback-функції: Вони дуже зручні для використання в методах масивів, таких як mapfilterreduce:

    const numbers = [1, 2, 3, 4, 5];
    const squared = numbers.map((num) => num ** 2);
    console.log(squared); // Виведе [1, 4, 9, 16, 25]
    

    Лексичне прив’язування this: Стрілкові функції автоматично прив’язують this до контексту, в якому вони були створені. Це уникне багатьох проблем, зокрема при роботі з об’єктами та подіями.

    Ланцюги обіцянок (Promises): Стрілкові функції можна використовувати в асинхронних операціях:

    const fetchData = async () => {
        try {
            const response = await fetch('https://api.example.com/data');
            const data = await response.json();
            console.log(data);
        } catch (error) {
            console.error('Something went wrong:', error);
        }
    };
    

    Параметри за замовчуванням та розпакування: Ви можете використовувати параметри за замовчуванням та розпаковування:

    const greet = (name = 'Friend') => `Hello, ${name}!`;
    console.log(greet()); // Виведе "Hello, Friend!"
    

    Отже, стрілкові функції – це не просто стріли, вони – ваші надійні помічники у світі JavaScript! 🚀1 2 3 4 5.

    How to View Connection History Remote Desktop on Windows 10

    Windows built-in Remote Desktop Connection makes it possible to access the computer remotely.  Wonder can you check remote desktop connection history? The answer is Yes! Here in this part, we provide you with two methods to view connection history of Remote Desktop on Windows 10, 11. Check the RDP connection history via Event Viewer.

    Step 1. Press Win + R to invoke the Run dialog box, then type in “eventvwr.msc” and press OK to open Event Viewer.

    Step 2. Navigate here: Applications and Services Logs > Microsoft > Windows > TerminalServicesRemoteConnectionManager > Operational. Right-click Operational and choose Filter Current Log.

    Step 3. The EventID of Remote Desktop Services is 1149. Then enter 1149 to filter the log.

    Step 4. Then you will get an event list with the history of all RDP connections to this server.

    Step 5. Click one of them, then you can see the details of the RDP connection, including IP address, computer name, login time, etc.

    How to Grow a Linux Partition with growpart

    Resizing Linux Virtual Machine Disks

    This article will show how to grow a partition on your Linux partition to fill the entire disk using growpart. This is useful if you have resized a virtual machine disk, or moved to a larger disk on your desktop or laptop Linux system.

    Step 1: Listing and Identifying Storage Devices

    To expand the filesystem on your resized disk, you’ll need to first locate the disk using the lsblk command, execute it by running:

    lsblk

    And you will see output similar to the following listing storage devices and the partitions on them:

    Above, you can see that disk sda has a size of 50 gigabytes, but that the volume containing the root partition (sda3) is only 29.5 gigabytes – there is unused space on the storage device.

    There may be multiple entries in the output from lsblk – you’ll need to identify the disk you have resized by the size and utilization – it should be apparent which disk has unused space. Usually on single-disk machines, the first and only storage device will be named sda.

    You will also need to know the name of the partition your wish to grow – in this case sda3 – usually identified by it having the root mount point of /.

    Step 2: Installing growpart

    growpart is a utility that makes it super easy to grow a partition. It’s part of the cloud-guest-utils package. Note that while this package is intended to work on cloud-hosted virtual machines, the growpart utility also works just fine on physical machines.

    On Debian and Ubuntu, run:

    sudo apt install cloud-guest-utils

    On Arch, run:

    pacman install cloud-guest-utils

    On RedHat, run:

    yum install cloud-utils-growpart -y

    Step 3: Grow your Partition

    Once growpart is available, growing a partition to use the entire remaining disk space is as simple as running:

    sudo growpart /dev/sda 3

    You’ll need to specify the correct partition name above, replaceing sda 3 (note the space! the device and partition number are separated when using growpart) if necessary. growpart is executed with no additional parameters – if the size parameter is not specified, it will default to the available size of the partition.

    Now that the partition has been expanded, the file system must be also using resize2fs:

    sudo resize2fs /dev/sda3

    Note that the space has disappeared in the device path again.

    You will see output similar to:

    Confirming the change. Once this final step is done, reboot:

    sudo reboot

    How to flush the DNS cache in Debian GNU/Linux?

    If using systemd-resolved as your DNS resolver (i.e. the hosts line of your /etc/nsswitch.conf file includes the word resolve and/or /etc/resolv.conf contains the line nameserver 127.0.0.53), then this command will flush its cache:

    sudo systemd-resolve --flush-caches

    A newer version of this command seems to be:

    sudo resolvectl flush-caches

    How to convert WMV to MP4

    You can use FFmpeg (a free command-line tool for Mac, Linux and Windows) to encode WMV to MP4. Here is an example syntax:

    ffmpeg -i input.wmv -c:v libx264 -crf 23 -c:a aac -q:a 100 output.mp4

    This will encode the video to H.264 video and AAC audio, using the default quality. To change the quality for the video, use a different CRF value, where lower means better, e.g. 20 or 18. For audio, 100% is the default quality. Increase the value for better quality.

    For the AppleTV specifically, this is what Apple says it supports:

    H.264 video up to 1080p, 30 frames per second, High or Main Profile level 4.0 or lower, Baseline profile level 3.0 or lower with AAC-LC audio up to 160 kbit/s per channel, 48 kHz, stereo audio in .m4v, .mp4, and .mov file formats

    So, you could use the following command to force the 30 Hz frame rate and High profile:

    ffmpeg -i input.wmv -c:v libx264 -crf 23 -profile:v high -r 30 -c:a aac -q:a 100 -ar 48000 output.mp4

    How to install SSH2 extension for PHP 7.4

    If You have an error like: Call to undefined function ssh2_connect() that’s mean that in your PHP not installed ssh2 extension.

    Install this extension is very simple, in Ubuntu Linux or other Debian based distribution just use the command:

    sudo apt install php7.4-ssh2

    This command will install ssh2 extension to Your PHP 7.4. If you use other PHP version, just change number in this command to Your version.

    Mikrotik wireless client disconnection at specified signal levels

    Allow everything on WLAN1 that has a signal above -87dBm (eg, signal between -86 and+120 dBm) , and allow even that signal to drop below -87 dBm for 30 sec.

    The allow is authenticate (associate) and forwarding (connect to other clients).
    The allow-signal-out-of-range is needed because devices are in their hands, so the signal fluctuates, but I prefer not to drop them immediately.

    To stop the weak signal connections on WLAN1 the next line is needed. For everything with signal between -87 and -120 dBm there is no authentication allowed.

    The allow-signal-out-of range is short here (1 sec) because this is used for roaming clients that are sticky to their first AP, but they may come back very soon to this AP, and I prefer not to deny them longer than needed.

    /interface wireless access-list
    add allow-signal-out-of-range=30s interface=wlan1 signal-range= -86..120 
    add allow-signal-out-of-range=1s authentication=no forwarding=no interface=wlan1 signal-range=-120..-87

    Create first program “Hello World” on Assembler in Linux

    To create program on Assembler in Linux operating system we need compiler for x86 architecture named nasm

    sudo apt install nasm

    To compile program in file hello.asm use commands:

    nasm -felf64 hello.asm
    ld hello.o
    

    To start compiled program use command:

    ./a.out

    Nov let’s create our program in file hello.asm using text editor vim

    vim hello.asm

    Here is the full code of program:

    message:
    	db	"Hello World!", 10
    
    _start:
    	mov	rax, 1
    	mov	rdi, 1
    	mov	rsi, message
    	mov	rdx, 14
    	syscall
    
    	mov	rax, 60
    	syscall
    
    	section .data
    
    global _start
    
    section .text

    In first two lines we create some label which contains some directive db width string “Hello World!“, and last symbol 10line feed. Directive is like variables in high level programming languages.

    Directive db can use 1 byte for writing information and can write constants from -128 to 255 and can write symbols and strings.

    Next create label _start: and width command mov we write some data in processor address (register):

    mov rax, 1 – move 1 in register rax – in this string we call data recording.
    mov rdi, 1 – This register response for input and output stream. When we send 1 in register rdi we say processor to work width standard output stream.
    mov rsi, message – we write address of our string in register rsi.
    mov rdx, 14 – we write count bytes of our string in register rdx.

    Next we make system call width command syscall.

    mov rax, 60 – we put number 60 in register rax – this is system call for exit.

    And again make system call width command syscall.

    At the end of program we run command section .data

    Width command global _start we run our program from label _start.

    Width command section .text we declare text part of our code

    Soltek SL-61D Specifications

    The specs for SL-61D comes in these configurations with a retail price tag. The configuration Soltek provides comes with a Intel Pentium II/III or Celeron Slot 1 Ultra ATA/33 PCI/ISA/AGP n/a,.

    This Soltek Motherboard can take up to 768 MB ram, with a fixed amount of 0 MB (removable) installed PC100 SDRAM DIMMs.

    This full-featured mainstream Motherboard enhances the previous generation Soltek models with the chipsets and new levels of customization. Get the best experience on your Soltek SL-61D Motherboard with improved performance, make it easy to create a home network and share all of your favorite items.

    The specs of Motherboard shows full configuration information. The SL-61D is designed for users who require maximum performance in a mainstream Motherboard. Even with its form factor design, the SL-61D doesn’t skimp on performance offering the ideal blend of power and efficiency. The SL-61D is sure to leave a lasting impression with its easy to use and slim design. Located on the side of the unit, the modular bay’s innovative latch is designed for easy insertion and removal of the various module options.

    The SL-61D Motherboard only supports Intel Pentium II/III or Celeron. The SL-61D features two on-board data caches for transferring information to and from the processor. These caches are known as the L1 and L2 caches. The SL-61D L1 cache is 64 kilobytes in size, while its L2 cache is rated at either one or two megabytes.

    When you have a clear idea of which Motherboard best suits your needs, check for its specifications. As the SL-61D is supported by Soltek, check if the Motherboard has full support and warranties by its manufacturer, like SL-61D specs you will have lots of options from the Motherboard manufacturer to choose from, like the Motherboard processor, Motherboard RAM, its graphics capacity, Motherboard display options and specs, and other features that the Motherboard provides.