Skip to content

A diverse collection of scripts, snippets, and functions

License

Notifications You must be signed in to change notification settings

voytas75/VoytasCodeLab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 

Repository files navigation

Welcome to VoytasCodeLab

ko-fi

Explore a diverse collection of my scripts, snippets, and functions across multiple programming languages. Whether you're working with PowerShell, Python, Bash, JavaScript, or more, VoytasCodeLab provides a valuable resource for automation, development, and learning. Dive into various coding examples and enhance your programming toolkit with Voytas.

The Code

  1. Get-CyclomaticComplexity

    Calculates the cyclomatic complexity of a PowerShell script or code block, including both functions and top-level code.

    PowerShell Gallery

    Published version: Powershell gallery

    Source code

    Example

    $code = @"
        if ($true) { Write-Output "True" }
        else { Write-Output "False" }
        function Test {
            if ($true) { Write-Output "True" }
            else { Write-Output "False" }
        }
        "@
    Get-CyclomaticComplexity -CodeBlock $code
    Get-CyclomaticComplexity -CodeBlock (Get-Content "D:\path\to\file.ps1" -raw)
    Get-CyclomaticComplexity -FilePath "C:\path\to\file.ps1"
  2. Random numbers

    A script to generate a series of random numbers using different methods and formats.

    The script uses both built-in PowerShell capabilities and .NET classes to generate random numbers. It showcases different ways to generate random numbers as UInt64 and UInt32, both as a full range and a fractional number between 0 and 1.

    If you need random numbers for cryptographic purposes, it's recommended to use classes from "System.Security.Cryptography", such as "RandomNumberGenerator", which provides cryptographic strength random number generation.

    Linkedin

    random.ps1

  3. Convert-YouTubeTranscript

    Converts a YouTube transcript into a structured format with timestamps and corresponding text.

    This script takes a YouTube transcript (glasp.co - transcript extension) as input and extracts the timestamps and their corresponding text. It returns an array of custom objects, each containing a timestamp and the associated text.

    Example

    $transcript = @"
    (00:00) on September 1st last year a team of 16 scientists made a stunning discovery that sent shock waves through the scientific Community they ...
    (05:52) essentially cease to exist for them they are momentary in a sense passing through the fabric of SpaceTime without experiencing the passage ...
    (10:09) unfolding this concept becomes even more exciting when applied to photons or particles of light photons have no clear past present or future ...
    (12:24) basic assumptions of The Big Bang Theory
    "@
    
    $results = Convert-YouTubeTranscript -transcript $transcript
    $results | Format-Table -AutoSize

    Source code

    transcript extension

About

A diverse collection of scripts, snippets, and functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published