Skip to content

Instantly share code, notes, and snippets.

my $path_logs = '/var/log/gifts/';
my $main_log = 'deliveries.log';
my $path_main_log = $path_logs ~ $main_log;
my $max_size_log = 20000000;
my $max_logs = 5;
exit unless $path_main_log.IO.e;
exit if $path_main_log.IO.s < $max_size_log;
my @log_files = $path_logs.IO.dir.grep(/$main_log$ | $main_log\d+$/).sort;
# Get Office 365 License Names from GUID
function Get-LicenseNamesByGUID {
param( [string] $GUID )
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$wc = New-Object System.Net.WebClient
$wc.Encoding = [System.Text.Encoding]::UTF8
$src = $wc.downloadstring('https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/licensing-service-plan-reference')
$delay_seconds = 1
while (1) {
$timestamp = Get-Date -Format "dd-MM-yyyy HH:mm:ss"
Try {
$connections = Get-NetTCPConnection -State Established -AppliedSetting Internet -ErrorAction Stop | select OwningProcess, RemoteAddress, RemotePort
use POSIX qw(strftime);
my $date, $remote_ip, $remote_port, $user, $group, $cmdpath;
while (1) {
foreach (`ss -tupn`) {
$date = strftime "%d-%m-%Y %H:%M:%S", localtime;
@ramiroencinas
ramiroencinas / ramix-getting-windows-memory-usage-with-nativecall.md
Last active November 30, 2020 15:54
Getting Windows Memory Usage with NativeCall

Getting Windows Memory Usage with NativeCall

Raku NativeCalls provide a way to interact with dynamic libraries that follow the C calling convention and are very useful for obtaining information from the operating system, such as memory usage.

In this article we will see how to get the memory usage from a Windows system.

The MEMORYSTATUSEX C++ structure

Win32 API provides the MEMORYSTATUSEX structure: