├── README.md ├── Remove-UnlinkedGPO.ps1 ├── Set-RegistryValueForAllUsers.ps1 ├── ansible-docker-container └── playbook.yml ├── availability_sets.tf ├── aws-athena └── app.py ├── aws-ocr ├── Job-Search-2.jpg ├── sample-journal.jpg └── sample-reciept.png ├── data-cleaning-python └── pokemon.csv ├── demo_csv.csv ├── get_unallocated_space.ps1 ├── github-actions-artifacts └── ci.yml ├── github-actions-matrix ├── .github │ └── workflows │ │ ├── example.yml │ │ ├── example2.yml │ │ ├── example3.yml │ │ ├── example4.yml │ │ ├── example5.yml │ │ ├── example6.yml │ │ └── example7.yml ├── README.md ├── css │ └── index.css ├── index.html └── js │ └── index.js ├── gitlab-ci ├── .gitlab-ci.yml ├── Dockerfile ├── app.py ├── requirements.txt ├── test_app.py └── wsgi.py ├── how-to-build-a-solid-ansible-playbook ├── lemp_ubuntu1804 │ ├── files │ │ ├── info.php.j2 │ │ └── nginx.conf.j2 │ ├── hosts │ ├── playbook.yml │ └── vars │ │ └── default.yml └── readme.md ├── how-to-set-up-an-nginx-reverse-proxy-in-docker-step-by-step ├── both │ ├── default.conf │ ├── docker-compose.yml │ └── dockerfile ├── nodejs │ ├── default.conf │ ├── docker-compose.yml │ ├── dockerfile │ └── index.js └── php │ ├── default.conf │ ├── docker-compose.yml │ ├── dockerfile │ └── index.php ├── power-bi-python ├── central.py └── invoices.py ├── psreadline ├── SamplePredictor.csproj └── SamplePredictorClass.cs ├── python-url-shortner ├── .gitignore ├── appspec.yml ├── codedeploy-files │ ├── Dockerfile │ ├── docker-compose.yml │ ├── requirements.txt │ └── routes.py ├── install_docker.sh ├── start.sh └── stop.sh ├── python-zip ├── all_black.bmp ├── all_blue.bmp ├── all_green.bmp ├── all_red.bmp └── demo.py ├── sample_cert_files.zip └── sample_data.csv /README.md: -------------------------------------------------------------------------------- 1 | # Scripts 2 | Collection of scripts associated with ATA posts. 3 | -------------------------------------------------------------------------------- /Remove-UnlinkedGPO.ps1: -------------------------------------------------------------------------------- 1 | Import-Module GroupPolicy 2 | $Date = Get-Date -Format dd_MM_yyyy 3 | $BackupDir = "c:\GPOBackup\$Date" 4 | ## Creates a directory to store the GPO reports 5 | if (-Not(Test-Path -Path $BackupDir)) { 6 | New-Item -ItemType Directory $BackupDir -Force 7 | } 8 | 9 | # Get all GPOs with the gpo report type as XML and also look for the section in the xml report. 10 | # Consider only the GPOs that doesnt have section. 11 | Get-GPO -All | Where-Object { $_ | Get-GPOReport -ReportType XML | Select-String -NotMatch "" } | ForEach-Object { 12 | # Backup the GPO, HTML report and saving the GPO details to text file are optional. 13 | Backup-GPO -Name $_.DisplayName -Path $BackupDir 14 | # Run the report and save as an HTML report to disk 15 | Get-GPOReport -Name $_.DisplayName -ReportType Html -Path "$BackupDir\$($_.DisplayName).html" 16 | # Create and append to a text file called UnlinkedGPOs.txt in the backup folder that 17 | # contains each GPO object that Get-GPO returns 18 | $_ | Select-Object * | Out-File "$BackupDir\UnLinkedGPOs.txt" -Append 19 | # Remove the GPO but first prompt before removing 20 | $_.Displayname | Remove-GPO -Confirm 21 | } 22 | -------------------------------------------------------------------------------- /Set-RegistryValueForAllUsers.ps1: -------------------------------------------------------------------------------- 1 | function Set-RegistryValueForAllUsers { 2 | <# 3 | .SYNOPSIS 4 | This function uses Active Setup to create a "seeder" key which creates or modifies a user-based registry value 5 | for all users on a computer. If the key path doesn't exist to the value, it will automatically create the key and add the value. 6 | .EXAMPLE 7 | PS> Set-RegistryValueForAllUsers -RegistryInstance @{'Name' = 'Setting'; 'Type' = 'String'; 'Value' = 'someval'; 'Path' = 'SOFTWARE\Microsoft\Windows\Something'} 8 | 9 | This example would modify the string registry value 'Type' in the path 'SOFTWARE\Microsoft\Windows\Something' to 'someval' 10 | for every user registry hive. 11 | .PARAMETER RegistryInstance 12 | A hash table containing key names of 'Name' designating the registry value name, 'Type' to designate the type 13 | of registry value which can be 'String,Binary,Dword,ExpandString or MultiString', 'Value' which is the value itself of the 14 | registry value and 'Path' designating the parent registry key the registry value is in. 15 | #> 16 | [CmdletBinding()] 17 | param ( 18 | [Parameter(Mandatory=$true)] 19 | [hashtable[]]$RegistryInstance 20 | ) 21 | try { 22 | New-PSDrive -Name HKU -PSProvider Registry -Root Registry::HKEY_USERS | Out-Null 23 | 24 | ## Change the registry values for the currently logged on user. Each logged on user SID is under HKEY_USERS 25 | $LoggedOnSids = (Get-ChildItem HKU: | Where-Object { $_.Name -match 'S-\d-\d+-(\d+-){1,14}\d+' }).PSChildName 26 | Write-Verbose "Found $($LoggedOnSids.Count) logged on user SIDs" 27 | foreach ($sid in $LoggedOnSids) { 28 | Write-Verbose -Message "Loading the user registry hive for the logged on SID $sid" 29 | foreach ($instance in $RegistryInstance) { 30 | ## Create the key path if it doesn't exist 31 | New-Item -Path "HKU:\$sid\$($instance.Path | Split-Path -Parent)" -Name ($instance.Path | Split-Path -Leaf) -Force | Out-Null 32 | ## Create (or modify) the value specified in the param 33 | Set-ItemProperty -Path "HKU:\$sid\$($instance.Path)" -Name $instance.Name -Value $instance.Value -Type $instance.Type -Force 34 | } 35 | } 36 | 37 | ## Create the Active Setup registry key so that the reg add cmd will get ran for each user 38 | ## logging into the machine. 39 | ## http://www.itninja.com/blog/view/an-active-setup-primer 40 | Write-Verbose "Setting Active Setup registry value to apply to all other users" 41 | foreach ($instance in $RegistryInstance) { 42 | ## Generate a unique value (usually a GUID) to use for Active Setup 43 | $Guid = [guid]::NewGuid().Guid 44 | $ActiveSetupRegParentPath = 'HKLM:\Software\Microsoft\Active Setup\Installed Components' 45 | ## Create the GUID registry key under the Active Setup key 46 | New-Item -Path $ActiveSetupRegParentPath -Name $Guid -Force | Out-Null 47 | $ActiveSetupRegPath = "HKLM:\Software\Microsoft\Active Setup\Installed Components\$Guid" 48 | Write-Verbose "Using registry path '$ActiveSetupRegPath'" 49 | 50 | ## Convert the registry value type to one that reg.exe can understand. This will be the 51 | ## type of value that's created for the value we want to set for all users 52 | switch ($instance.Type) { 53 | 'String' { 54 | $RegValueType = 'REG_SZ' 55 | } 56 | 'Dword' { 57 | $RegValueType = 'REG_DWORD' 58 | } 59 | 'Binary' { 60 | $RegValueType = 'REG_BINARY' 61 | } 62 | 'ExpandString' { 63 | $RegValueType = 'REG_EXPAND_SZ' 64 | } 65 | 'MultiString' { 66 | $RegValueType = 'REG_MULTI_SZ' 67 | } 68 | default { 69 | throw "Registry type '$($instance.Type)' not recognized" 70 | } 71 | } 72 | 73 | ## Build the registry value to use for Active Setup which is the command to create the registry value in all user hives 74 | $ActiveSetupValue = 'reg add "{0}" /v {1} /t {2} /d {3} /f' -f "HKCU\$($instance.Path)", $instance.Name, $RegValueType, $instance.Value 75 | Write-Verbose -Message "Active setup value is '$ActiveSetupValue'" 76 | ## Create the necessary Active Setup registry values 77 | Set-ItemProperty -Path $ActiveSetupRegPath -Name '(Default)' -Value 'Active Setup Test' -Force 78 | Set-ItemProperty -Path $ActiveSetupRegPath -Name 'Version' -Value '1' -Force 79 | Set-ItemProperty -Path $ActiveSetupRegPath -Name 'StubPath' -Value $ActiveSetupValue -Force 80 | } 81 | } catch { 82 | Write-Warning -Message $_.Exception.Message 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /ansible-docker-container/playbook.yml: -------------------------------------------------------------------------------- 1 | # Separate directives from document content. 2 | # Signals the start of a document if no directives are present. 3 | --- 4 | - hosts: all # Sets the playbook to run on all hosts. 5 | become: true # Tells Ansible to run all tasks as the root user. 6 | vars: # Sets variables 7 | # Defines how many containers to deploy 8 | container_count: 4 9 | # Define the name and image of the container to deploy. 10 | default_container_name: docker 11 | default_container_image: ubuntu 12 | # Defines the command to run inside the container. 13 | default_container_command: sleep 1d 14 | 15 | # Define tasks Ansible will take action upon 16 | tasks: 17 | # Install aptitude package manager for Debian-based systems 18 | - name: Install aptitude 19 | apt: 20 | name: aptitude 21 | state: latest 22 | update_cache: true 23 | 24 | # Install packages essential for running a developer environment 25 | # on a Debian-based system. 26 | - name: Install required system packages 27 | apt: 28 | pkg: 29 | - apt-transport-https 30 | - ca-certificates 31 | - curl 32 | - software-properties-common 33 | - python3-pip 34 | - virtualenv 35 | - python3-setuptools 36 | state: latest 37 | update_cache: true 38 | 39 | # Sets key used to verify your install packages are from an authorized source. 40 | - name: Add Docker GPG apt Key 41 | apt_key: 42 | url: https://download.docker.com/linux/ubuntu/gpg 43 | state: present 44 | 45 | # Sets repository containing packages needed to install 46 | # and run Docker on a Debian-based system. 47 | - name: Add Docker Repository 48 | apt_repository: 49 | repo: deb https://download.docker.com/linux/ubuntu focal stable 50 | state: present 51 | 52 | # Installs Docker community edition 53 | - name: Update apt and install docker-ce 54 | apt: 55 | name: docker-ce 56 | state: latest 57 | update_cache: true 58 | 59 | # Installs Docker Module for Python. 60 | # Allows you to manage Docker containers from within Ansible playbooks. 61 | - name: Install Docker Module for Python 62 | pip: 63 | name: docker 64 | 65 | # Pulls the default docker image (Ubuntu) 66 | - name: Pull default Docker image 67 | community.docker.docker_image: 68 | name: "{{ default_container_image }}" 69 | source: pull 70 | 71 | # Create four containers on each managed host using default image and command. 72 | - name: Create default containers 73 | community.docker.docker_container: 74 | name: "{{ default_container_name }}{{ item }}" 75 | image: "{{ default_container_image }}" 76 | command: "{{ default_container_command }}" 77 | state: present 78 | # Tells Ansible to repeat tasks for each item in the container_count variable 79 | with_sequence: count={{ container_count }} -------------------------------------------------------------------------------- /availability_sets.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | required_providers { 3 | azurerm = { 4 | source = "hashicorp/azurerm" 5 | version = "~>2.64.0" 6 | } 7 | } 8 | } 9 | 10 | provider "azurerm" { 11 | features {} 12 | } 13 | 14 | resource "azurerm_resource_group" "rg" { 15 | name = "avsetdemo-rg" 16 | location = "westus2" 17 | } 18 | 19 | resource "azurerm_virtual_network" "vnet" { 20 | name = "vnet-app" 21 | resource_group_name = azurerm_resource_group.rg.name 22 | location = azurerm_resource_group.rg.location 23 | address_space = ["10.0.0.0/16"] 24 | } 25 | 26 | resource "azurerm_subnet" "snet-logs" { 27 | name = "snet-logs" 28 | virtual_network_name = azurerm_virtual_network.vnet.name 29 | resource_group_name = azurerm_resource_group.rg.name 30 | address_prefixes = ["10.0.2.0/24"] 31 | } 32 | 33 | resource "azurerm_availability_set" "avset-db" { 34 | name = "avset-db" 35 | resource_group_name = azurerm_resource_group.rg.name 36 | location = azurerm_resource_group.rg.location 37 | platform_fault_domain_count = 3 38 | platform_update_domain_count = 3 39 | managed = true 40 | } 41 | 42 | resource "azurerm_network_interface" "nics" { 43 | count = 10 44 | name = "db0${count.index + 1}-nic" 45 | resource_group_name = azurerm_resource_group.rg.name 46 | location = azurerm_resource_group.rg.location 47 | 48 | ip_configuration { 49 | name = "internal" 50 | subnet_id = azurerm_subnet.snet-logs.id 51 | private_ip_address_allocation = "Dynamic" 52 | } 53 | } 54 | 55 | resource "azurerm_linux_virtual_machine" "dbs" { 56 | count = 10 57 | name = "db0${count.index + 1}" 58 | resource_group_name = azurerm_resource_group.rg.name 59 | location = azurerm_resource_group.rg.location 60 | size = "Standard_DS1_v2" 61 | admin_username = "adminuser" 62 | admin_password = "N0t@Pa$$word!" 63 | disable_password_authentication = false 64 | network_interface_ids = [ 65 | "${azurerm_network_interface.nics.*.id[count.index]}" 66 | ] 67 | availability_set_id = azurerm_availability_set.avset-db.id 68 | 69 | os_disk { 70 | caching = "ReadWrite" 71 | storage_account_type = "Standard_LRS" 72 | } 73 | 74 | source_image_reference { 75 | publisher = "Canonical" 76 | offer = "UbuntuServer" 77 | sku = "16.04-LTS" 78 | version = "latest" 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /aws-athena/app.py: -------------------------------------------------------------------------------- 1 | import boto3 2 | import pandas as pd 3 | import io 4 | import re 5 | import time 6 | 7 | # region - The region where you created your database. 8 | # database - The name of the database. 9 | # bucket - Your bucket name. 10 | # path - The location where the results of the queries will be stored. 11 | # query - store data in the exact location as the CSV file. 12 | 13 | params = { 14 | 'region': 'us-east-2', 15 | 'database': 'default', 16 | 'bucket': 'athena-112', 17 | 'path': 'temp/athena/results', 18 | 'query': 'SELECT * FROM "default"."athena-112" limit 10;' 19 | } 20 | 21 | session = boto3.Session() 22 | 23 | def athena_query(client, params): 24 | 25 | # start_query_execution method - runs the SQL query statements. 26 | # QueryString - has SQL query statements to be executed. 27 | # QueryExecutionContext - has the database within which the query executes. 28 | # ResultConfiguration - specifies information about where and 29 | # how to save the results of the query execution. 30 | # All the information is dispatched to an executable object response 31 | 32 | response = client.start_query_execution( 33 | QueryString=params["query"], 34 | QueryExecutionContext={ 35 | 'Database': params['database'] 36 | }, 37 | ResultConfiguration={ 38 | 'OutputLocation': 's3://' + params['bucket'] + '/' + params['path'] 39 | } 40 | ) 41 | print(response) 42 | return response 43 | 44 | 45 | # Information about the query execution is saved with a unique ID. 46 | 47 | def athena_to_s3(session, params, max_execution = 5): 48 | client = session.client('athena', region_name=params["region"]) 49 | execution = athena_query(client, params) 50 | execution_id = execution['QueryExecutionId'] 51 | state = 'RUNNING' 52 | 53 | # Validates and stores information about the successful execution of a query 54 | # and store the information to the specified path in an S3 bucket 55 | 56 | while (max_execution > 0 and state in ['RUNNING', 'QUEUED']): 57 | max_execution = max_execution - 1 58 | response = client.get_query_execution(QueryExecutionId = execution_id) 59 | 60 | if 'QueryExecution' in response and \ 61 | 'Status' in response['QueryExecution'] and \ 62 | 'State' in response['QueryExecution']['Status']: 63 | state = response['QueryExecution']['Status']['State'] 64 | if state == 'FAILED': 65 | return False 66 | elif state == 'SUCCEEDED': 67 | s3_path = response['QueryExecution']['ResultConfiguration']['OutputLocation'] 68 | filename = re.findall('.*\/(.*)', s3_path)[0] 69 | return filename 70 | time.sleep(1) 71 | 72 | return False 73 | 74 | # Calling above function 75 | s3_filename = athena_to_s3(session, params) 76 | 77 | 78 | # Cleanup method will delete the results of queries from the specified path 79 | 80 | def cleanup(session, params): 81 | s3 = session.resource('s3') 82 | my_bucket = s3.Bucket(params['bucket']) 83 | for item in my_bucket.objects.filter(Prefix=params['path']): 84 | item.delete() 85 | 86 | # Calls the cleanup function to remove all files from the specified S3 folder 87 | cleanup(session, params) -------------------------------------------------------------------------------- /aws-ocr/Job-Search-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/aws-ocr/Job-Search-2.jpg -------------------------------------------------------------------------------- /aws-ocr/sample-journal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/aws-ocr/sample-journal.jpg -------------------------------------------------------------------------------- /aws-ocr/sample-reciept.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/aws-ocr/sample-reciept.png -------------------------------------------------------------------------------- /data-cleaning-python/pokemon.csv: -------------------------------------------------------------------------------- 1 | Name,Height (in),Weight (lbs),Type,Weaknesses 2 | Bulbasaur,28,15.2," Grass, Poison"," Fire, Psychic, Flying, Ie" 3 | Ivysaur,39,28.7,"Grass, Poison","Fire, Psychic, Flying, Ice" 4 | Venusaur,79,220.5,"Grass, Poison"," Fire, Psychic, Flying, Ice" 5 | Charmander,24,18.7,Fire," Water, Ground, Rock" 6 | Charmeleon,43,41.9,Fire," Water, Ground, Rock" 7 | Charizard,67,199.5,"Fire, Flying","Water, Electric, Rock" 8 | Squirtle,20,19.8,Water,"Gras, Electric" 9 | Wartortle,39,49.6,Water,"Grass, Electric" 10 | Blastoise,63 inches,188.5,Water,"Grass, Electric" 11 | Blastoise,63,188.5,Water,"Grass, Electric" 12 | Caterpie,12,6.4,Bug,"Fire, Flying, Rock" 13 | Metapod,28,21.8,Bug,"Fire, Flying, Rock " 14 | Butterfree,43,70.5,"Bug, Flying","Fire, Flying, Electric, Ice, Rock" 15 | Weedle,12,7.1,"Bug, Poison","Fire, Psychic, Flying, Rock" 16 | Kakuna,24,22,"Bug, Poison","Fire, Psychic, Flying, Rock" 17 | Beedrill,39,65,"Bug, Poison","Fire, Psychic, Flying, Rock" 18 | Pidgey,12,4,"Normal, Flying","Electric, Ice, Rock" 19 | Pidgeotto,43,66.1,"Normal, Flying","Electric, Ic, Rock" 20 | Pidgeot,59,87.1,"Normal, Flying","Electric, Ice, Rock" 21 | Rattata,12,7.7,Normal,Fighting 22 | Raticate,28,40.8,Normal,Fighting 23 | Spearow,12,4.4,"Normal, Flying","Electric, Ie, Rock" 24 | Fearow,47,83.8,"Normal, Flying","Electric, Ice, Rock" 25 | Ekans,79,15.2,Poison,"Psychic, Ground" 26 | Arbok,138,143.30lbs,Posion,"Psychic, Ground" 27 | Pikachu,16,13.2,Electric,Ground 28 | Raichu,31,66.1,Electric,Ground 29 | Sandshrew,24,26.5,Ground,"Water, Grass, Ice" 30 | Sandslash,39,65,Ground,"Water, Grass, Ice" 31 | Nidoran (f),"16""",15.4,Poison,"Psychic, Ground" 32 | Nidorina,31,44.1,Posion,"Psychic, Ground" 33 | Nidoqueen,51,132.3,"Posion, Ground","Water, Psychic, Ice, Ground" 34 | Nidoran (m),20,19.8,Posion,"Psychic, Ground" 35 | Nidorino,35,43,Poison,"Psychic, Ground" 36 | Nidoking,55,136.7,"Poison, Ground","Water, Psychic, Ice, Ground" 37 | Unknown,24,16.5,Fairy,"Steel, Posion" 38 | Clefable,fifty one,88.2,Fairy,"Steel, Posion" 39 | Vulpix,24,21.8,Fire,"Water, Ground, Rock" 40 | Ninetales,43,43.9,Fire,"Water, Ground, Rock" 41 | Jigglypuff,20,12.1,"Normal, Fairy","Steel, Posion" 42 | Wigglytuff,39,26.5,"Normal, Fairy","Steel, Posion" 43 | Zubat,31,16.5,"Poison, Flying","Psychic, Electric, Ice, Rock" 44 | Golbat,,,"Poison, Flying","Psychic, Electric, Ice, Rock" 45 | Oddish,20,11.9,"Grass, Poison","Fire, Psychic, Flying, Ice" 46 | Gloom,31,19,"Grass, Poison","Fire, Psychic, Flying, Ice" 47 | Vileplume,47,41,"Grass, Poison","Fire, Psychic, Flying, Ice" 48 | Paras,12,11.9,"Bug, Grass ","Fire, Flying, Ice, Poison, Rock, Bug" 49 | Parasect,39,65,"Bug, Grass","Fire, Flying, Ice, Poison, Rock, Bug" 50 | Ekans,79,15.2,Poison,"Psychic, Ground" 51 | Venonat,39,66.1,"Bug, Poison","Fire, Psychic, Flying, Rock" 52 | Venomoth,59,27.6,"Bug, Poison ","Fire, Psychic, Flying, Rock" 53 | Diglett,8,1.8,Ground,"Water, Grass, Ice" 54 | Dugtrio,28,73.4,Ground,"Water, Grass, Ice" 55 | Meowth,16,9.3,Normal,Fighting 56 | Persian,39,70.5,Normal,Fighting 57 | Psyduck,31,43.2,Water,Grass - Electric 58 | Golduck,67,168.9,Water,"Grass, Electric" 59 | Mankey,20,61.7,Fighting,"Psychic, Flying, Fairy" 60 | Primeape,39,70.5,Fighting,"Psychic, Flyng, Fairy" 61 | Growlithe,28,41.9,Fire,"Water, Ground, Rock" 62 | Arcanine,75,341.7,Fire,"Water, Ground, Rock" 63 | Poliwag,24,27.3,Water,"Grass, Electric" 64 | Poliwhirl,39,44.1,Water,"Grass, Electric" 65 | Poliwrath,51,119,"Water, Fighting","Fairy, Grass, Flying, Psychic, Electric" 66 | Abra,35,43,Psychic,"Ghost, Dark, Bug" 67 | Kadabra,51,124.6,Psychic,"Ghost, Dark, Bug" 68 | Alakazam,59,-105.8,Psychic,"Ghost, Dark, Bug" 69 | Machop,31,43,Fighting,"Psychic, Flying, Fairy" 70 | Machoke,59,155.4,,"Psychic, Flying, Fairy" 71 | Machamp,63,286.6,Fighting,"Psychic, Flying, Fairy" 72 | Bellsprout,16,8.8,"Grass, Poison","Fire, Psychic, Flying, Ice" 73 | Weepinbell,39,14.1,"Grass, Poison","Fire, Psychic, Flying, Ice" 74 | Victreebell,67,34.2,"Grass, Poison","Fire, Psychic, Flying, Ice" 75 | Tentacool,35,100.3,"Water, Poison","Psychic, Electric, Ground" 76 | Tentacruel,63,121.3,"Water, Poison","Psychic, Electric, Ground" 77 | Geodude,16,44.1,"Rock, Ground","Steel, Fighting, Water, Ice, Grass, Ground" 78 | Graveler,"39""",231.5,"Rock, Ground","Steel, Fighting, Water, Ice, Grass, Ground" 79 | Golem,55,661.4,"Rock, Ground","Steel, Fighting, Water, Ice, Grass, Ground" 80 | Ponyta,39,66.10lbs,Fie,"Water, Ground, Rock" 81 | Rapidash,67,209.4,Fire,"Water, Ground, Rock" 82 | Slowpoke,47,79.4,"Water, Psychic","Ghost, Dark, Grass, Electric, Bug" 83 | Slowbro,63,173.1,"Water, Psychic","Ghost, Dark, Grass, Electric, Bug" 84 | Magnemite,12,13.2,"Electric, Steel","Fire, Fighting, Ground" 85 | Magneton,39,132.3,"Electric, Steel","Fire, Fighting, Ground" 86 | Farfetch'd,31,33.1,"Normal, Flying","Electric, Ice, Rock" 87 | Doduo,55,86.4,"Normal, Flying","Electric, Ice, Rock" 88 | Dodrio,71,187.8,"Normal, Flying","Electric, Ice, Rock" 89 | Seel,43,198.4,,"Grass, Electric" 90 | Dewgong,67,264.6,"Water, Ice ","Grass, Electric, Flying, Rock" 91 | Grimer,35,66.1,Poison,"Psychic, Ground" 92 | Muk,47,66.1,Poison,"Psychic, Ground " 93 | Farfetch'd,31,33.1,"Normal, Flying","Electric, Ice, Rock" 94 | Shelder,12,8.8,Water,"Grass, Electric" 95 | Cloyster,59,292.1,"Water, Ice","Grass, Electric, Fighting, Rock" 96 | Gastly,51,0.2,"Ghost, Poison","Ghost, Dark, Psychic, Ground" 97 | Haunter,63,0.2,"Ghost, Poison","Ghost, Dark, Psychic, Ground" 98 | Gengar,59,89.3,"Ghost, Poison","Ghost, Dark, Psychic, Ground" 99 | Onix,346,463,"Rock, Ground","Steel, Fighting, Water, Ice, Grass, Ground" 100 | Drowzee,39,71.4,Psychic,"Ghost, Dark, Bug" 101 | Hypno,63,166.7,Psychic,"Ghost, Dark, Bug" 102 | Krabby,16,14.3,Water,"Grass, Electric" 103 | Kingler,51,132.3,Water,"Grass, Electric " 104 | Voltorb,16,5.5,"Grass, Psychic",Ghost - Fire - Flying - Ice - Dark - Poison - Bug 105 | Electrode,47,146.8,Electric,Ground 106 | Exeggcute,16,5.5,"Grass, Psychic","Ghost, Fire, Flying, Ice, Dark, Poison, Bug" 107 | Exeggutor,79,264.6,"Grass, Psychic","Ghost, Fire, Flying, Ice, Dark, Poison, Bug" 108 | Cubone,16,14.3,Ground,"Water, Grass, Ice" 109 | Marowak,39,99.2,Ground,"Water, Grass, Ice" 110 | Hitmonlee,59,109.8,Fighting,"Psychic, Flying, Fairy" 111 | Hitmonchan,55,110.7,Fighting,"Psychic, Flying, Fairy" 112 | Lickitung,47,-144.4,Normal,Fighting 113 | Koffing,24,2.2,Poison,"Psychic, Ground" 114 | Weezing,47,20.9,Poison,"Psychic, Ground" 115 | Rhyhorn,39,253.5,"Ground, Rock","Steel, Ice, Water, Fighting, Grass, Ground" 116 | Rhydon,75,264.6,"Ground, Rock","Steel, Ice, Water, Fighting, Grass, Ground" 117 | Chansey,43,76.3,Normal,Fighting 118 | Tangela,39,77.2,Grass,"Fire, Flying, Ice, Poison, Bug" 119 | Kangaskhan,87,176.4,Normal,Fighting 120 | Horsea,16,17.6,Water,"Grass, Electric" 121 | Seadra,47,55.1,Water,"Grass, Electric" 122 | Goldeen,24,33.1,Unknown,"Grass, Electric" 123 | Seaking,51,86,Water,"Grass, Electric" 124 | Staryu,31,76.1,Water,"Grass, Electric" 125 | Starmie,43,176.4,"Water, Psychic","Ghost, Dark, Grass, Electric, Bug" 126 | Mr. Mime,51,120.2,"Psychic, Fairy","Ghost, Steel, Poison" 127 | Scyther,59,123.5,"Bug, Flying","Fire, Flying, Electric, Ice, Rock" 128 | Jynx,55,89.5,"Ice, Psychic","Steel, Ghost, Fire, Dark, Rock, Bug" 129 | Electrabuzz,43,66.1,Electric,Ground 130 | Magmar,51,98.1,Fire,"Water, Ground, Rock" 131 | Pinsir,fifty nine,121.3,Bug,"Fire, Flying, Rock" 132 | Tauros,55,194.9,Normal,Fighting 133 | Magikarp,35,22,Water,"Grass, Electric" 134 | Gyrados,256,518.1,"Water, Flying","Electric, Rock" 135 | Lapras,98,485,"Water, Ice","Grass, Electric, Fighting, Rock" 136 | Ditto,12,8.8,Normal,Fighting 137 | Eevee,12,14.3,Normal,Fighting 138 | Vaporeon,39,63.9,Water,"Grass, Electric" 139 | Jolteon,31,54,Electric,Ground 140 | Flareon,35,55.1,Fire,"Water, Ground, Rock" 141 | Porygon,31,80.5,Normal,Fighting 142 | Omanyte,16,16.5,"Rock, Water","Grass, Electric, Fighting, Ground" 143 | Omastar,39,77.2,"Rock, Water","Grass, Electric, Fighting, Ground" 144 | Kabuto,20,25.4,"Rock, Water","Grass, Electric, Fighting, Ground" 145 | Kabutops,51,89.3,"Rock, Water","Grass, Electric, Fighting, Ground" 146 | Aerodactyl,71,130.1,"Rock, Flying","Steel, Water, Electric, Ice, Rock" 147 | Snorlax,83,"1,014.10",Normal,Fighting 148 | Articuno,67,122.1,"Ice, Flying","Steel, Fire, Electric, Rock" 149 | Zapdos,63,116,"Electric, Flying","Ice, Rock" 150 | Moltres,79,Nan,"Fire, Flying","Water, Electric, Rock" 151 | Dratini,71,7.3,Dragon,"Fairy, Ice, Dragon" 152 | Dragonair,157,36.4,Dragon,"Fairy, Ice, Dragon" 153 | Dragonite,87,463,"Dragon, Flying","Fairy, Dragon, Ice, Rock" 154 | Mewtwo,79,269,Psychic,"Ghost, Dark, Bug" 155 | Mew,Unknown,8.8,Psychic,"Ghost, Dark, Bug" -------------------------------------------------------------------------------- /demo_csv.csv: -------------------------------------------------------------------------------- 1 | "Name", "Sex", "Age", "Height (in)", "Weight (lbs)" 2 | "Alex", "M", 41, 74, 170 3 | "Bert", "M", 42, 68, 166 4 | "Carl", "M", 32, 70, 155 5 | "Dave", "M", 39, 72, 167 6 | "Elly", "F", 30, 66, 124 7 | "Fran", "F", 33, 66, 115 8 | "Gwen", "F", 26, 64, 121 9 | "Hank", "M", 30, 71, 158 10 | "Ivan", "M", 53, 72, 175 11 | "Jake", "M", 32, 69, 143 12 | "Kate", "F", 47, 69, 139 13 | "Luke", "M", 34, 72, 163 14 | "Myra", "F", 23, 62, 98 15 | "Neil", "M", 36, 75, 160 16 | "Omar", "M", 38, 70, 145 17 | "Page", "F", 31, 67, 135 18 | "Quin", "M", 29, 71, 176 19 | "Ruth", "F", 28, 65, 131 20 | -------------------------------------------------------------------------------- /get_unallocated_space.ps1: -------------------------------------------------------------------------------- 1 | $Disks = Get-CIMInstance -ClassName 'Win32_DiskDrive' 2 | $Partitions = Get-CIMInstance -ClassName 'Win32_DiskPartition' 3 | 4 | $Disks | ForEach-Object { 5 | [PSCustomObject]@{ 6 | "Disk Index" = $PSItem.Index 7 | "Partition Count" = ($Partitions | Where-Object DiskIndex -EQ $PSItem.Index) | Measure-Object | Select-Object -ExpandProperty Count 8 | "Total Space(MB)" = $PSItem.Size / 1MB 9 | "Unallocated Space(MB)" = ($PSItem.Size - ($Partitions | Where-Object DiskIndex -EQ $PSItem.Index | Measure-Object -Property Size -Sum).Sum) / 1MB 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /github-actions-artifacts/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ "main" ] 6 | pull_request: 7 | branches: [ "main" ] 8 | 9 | jobs: 10 | build: 11 | name: Build 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [12.x, 14.x, 16.x] 17 | steps: 18 | - uses: actions/checkout@v3 19 | - name: Use Node.js ${{ matrix.node-version }} 20 | uses: actions/setup-node@v3 21 | with: 22 | node-version: ${{ matrix.node-version }} 23 | - name: Install dependencies 24 | run: npm ci 25 | 26 | - name: Build app 27 | run: npm run build 28 | 29 | - name: Run tests 30 | run: npm run test 31 | - name: Upload production-ready build files 32 | uses: actions/upload-artifact@v3 33 | with: 34 | name: production 35 | path: ./build 36 | 37 | deploy: 38 | name: Deploy 39 | needs: build 40 | runs-on: ubuntu-latest 41 | 42 | steps: 43 | - name: Download artifact 44 | uses: actions/download-artifact@v3 45 | with: 46 | name: production 47 | path: ./build 48 | 49 | - name: Deploy to Netlify 50 | uses: netlify/actions/cli@master 51 | env: 52 | NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} 53 | NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} 54 | with: 55 | args: deploy --dir=build --prod 56 | -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example.yml: -------------------------------------------------------------------------------- 1 | name: Matrix Strategy Sample 2 | on: push 3 | jobs: 4 | example_matrix: 5 | strategy: 6 | matrix: 7 | os: [ubuntu-latest, windows-latest] 8 | version: [10, 12, 14] 9 | runs-on: ${{ matrix.os }} 10 | steps: 11 | - uses: actions/setup-node@v3 12 | with: 13 | node-version: ${{ matrix.version }} -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example2.yml: -------------------------------------------------------------------------------- 1 | 2 | name: Matrix Strategy Max-Parallel Sample 3 | on: push 4 | jobs: 5 | example_matrix: 6 | strategy: 7 | max-parallel: 4 8 | matrix: 9 | os: [ubuntu-latest, windows-latest] 10 | version: [10, 12, 14] 11 | runs-on: ${{ matrix.os }} 12 | steps: 13 | - uses: actions/setup-node@v3 14 | with: 15 | node-version: ${{ matrix.version }} -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example3.yml: -------------------------------------------------------------------------------- 1 | name: Matrix Strategy Include Sample 2 | on: push 3 | jobs: 4 | example_matrix: 5 | strategy: 6 | matrix: 7 | os: [ ubuntu-latest,windows-latest,] 8 | node: [12, 14, 16] 9 | include: 10 | - os: windows-latest 11 | node: 16 12 | npm: 8 13 | runs-on: ${{ matrix.os }} 14 | steps: 15 | - uses: actions/setup-node@v3 16 | with: 17 | node-version: ${{ matrix.node }} 18 | - if: ${{ matrix.npm }} 19 | run: npm install -g npm@${{ matrix.npm }} 20 | - run: npm --version -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example4.yml: -------------------------------------------------------------------------------- 1 | name: Matrix Strategy Include Sample2 2 | on: push 3 | jobs: 4 | job1: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | matrix: 8 | run: ['run1', 'run2'] 9 | include: 10 | - run: 'run3' 11 | steps: 12 | - run: echo Run ${{ matrix.run }} 13 | - run: date 14 | - run: sleep 1 15 | - run: date -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example5.yml: -------------------------------------------------------------------------------- 1 | name: Sample Run Include Syntax Json Format 2 | on: push 3 | jobs: 4 | job1: 5 | runs-on: ubuntu-latest 6 | outputs: 7 | matrix: ${{ steps.setmatrix.outputs.matrix }} 8 | steps: 9 | - name: Set Dynamic Matrix 10 | id: setmatrix 11 | run: | 12 | matrixStringifiedObject="{\"include\":[{\"run\":\"run1\"},{\"run\":\"run2\"}]}" 13 | echo "::set-output name=matrix::$matrixStringifiedObject" 14 | job2: 15 | needs: job1 16 | runs-on: ubuntu-latest 17 | strategy: 18 | matrix: ${{ fromJson(needs.job1.outputs.matrix) }} 19 | steps: 20 | - run: echo Run ${{ matrix.run }} 21 | - run: date 22 | - run: sleep 1 23 | - run: date -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example6.yml: -------------------------------------------------------------------------------- 1 | name: Sample Should Fail Run 1 Only 2 | on: push 3 | jobs: 4 | job: 5 | runs-on: ubuntu-latest 6 | strategy: 7 | fail-fast: false 8 | matrix: 9 | run: ['run1', 'run2'] 10 | steps: 11 | - run: echo Run ${{ matrix.run }} 12 | - run: date 13 | - name: Exit early if matrix run is run1 14 | run: '[ "${{ matrix.run }}" = "run1" ] && exit 1 || echo "continue"' 15 | - run: sleep 5 # Sleep to make sure all process that don't match above check don't finish before the one that will exit 16 | - run: date -------------------------------------------------------------------------------- /github-actions-matrix/.github/workflows/example7.yml: -------------------------------------------------------------------------------- 1 | name: Continue on Error 2 | on: push 3 | jobs: 4 | job: 5 | runs-on: ubuntu-latest 6 | continue-on-error: true 7 | strategy: 8 | # fail-fast: false 9 | matrix: 10 | run: ['run1', 'run2'] 11 | steps: 12 | - run: echo Run ${{ matrix.run }} 13 | - run: date 14 | - name: Exit early if matrix run is run1 15 | run: '[ "${{ matrix.run }}" = "run1" ] && exit 1 || echo "continue"' 16 | - run: sleep 5 # Sleep to make sure all process that don't match above check don't finish before the one that will exit 17 | - run: date -------------------------------------------------------------------------------- /github-actions-matrix/README.md: -------------------------------------------------------------------------------- 1 | ## This is a Currency Conveter App that convert between different currencies. 2 | -------------------------------------------------------------------------------- /github-actions-matrix/css/index.css: -------------------------------------------------------------------------------- 1 | *{ 2 | background-color: #1c1424; 3 | margin: 0; 4 | padding: 0; 5 | color: #d6d6d6; 6 | font-family: 'Recursive', sans-serif; 7 | } 8 | 9 | .left h1{ 10 | font-size: 60px; 11 | margin:160px 0 0 20px ; 12 | } 13 | 14 | .left p{ 15 | margin-left: 20px; 16 | } 17 | 18 | .left button{ 19 | height: 50px; 20 | width: 150px; 21 | border-radius: 20px; 22 | margin-left: 20px; 23 | border: 1px white solid; 24 | } 25 | 26 | .right h4{ 27 | margin-top: 80px; 28 | } 29 | 30 | .right form{ 31 | height: 75vh; 32 | background-color: #342b47; 33 | width:30vw; 34 | margin: 20px 0 0 70px; 35 | clear: both; 36 | border-radius: 8px; 37 | padding: 30px; 38 | } 39 | 40 | .right form input{ 41 | width: 100%; 42 | border-radius: 6px; 43 | height: 40px; 44 | padding: 8px; 45 | border: none; 46 | margin-bottom: 10px; 47 | } 48 | 49 | 50 | .right form div{ 51 | width: 100%; 52 | margin-bottom: 10px; 53 | height: 50px; 54 | padding: 30px 10px 0 10px; 55 | } 56 | 57 | .color1{ 58 | background-color: #4a142d; 59 | } 60 | .color2{ 61 | background-color: #8c0d28; 62 | } 63 | 64 | .color3{ 65 | background-color: mediumblue; 66 | } 67 | 68 | @media screen and (max-width:1024px){ 69 | 70 | .left h1{ 71 | font-size: 50px; 72 | margin:160px 0 0 10px ; 73 | } 74 | 75 | .left p{ 76 | margin-left: 10px; 77 | } 78 | 79 | .left button{ 80 | height: 50px; 81 | width: 150px; 82 | border-radius: 20px; 83 | margin-left: 10px; 84 | border: 1px white solid; 85 | } 86 | 87 | .right h4{ 88 | margin-top: 80px; 89 | } 90 | 91 | .right form{ 92 | height: 40vh; 93 | background-color: #342b47; 94 | width: 40vw; 95 | margin: 20px 0 0 70px; 96 | clear: both; 97 | border-radius: 8px; 98 | padding: 30px; 99 | } 100 | 101 | .right form input{ 102 | width: 100%; 103 | border-radius: 6px; 104 | height: 40px; 105 | padding: 8px; 106 | border: none; 107 | margin-bottom: 10px; 108 | } 109 | 110 | 111 | .right form div{ 112 | width: 100%; 113 | margin-bottom: 10px; 114 | height: 50px; 115 | padding: 30px 10px 0 10px; 116 | } 117 | 118 | 119 | } 120 | 121 | @media screen and (max-width:480px){ 122 | 123 | .left h1{ 124 | font-size: 30px; 125 | margin:160px 0 0 10px ; 126 | } 127 | 128 | .left p{ 129 | margin-left: 10px; 130 | } 131 | 132 | .left button{ 133 | height: 50px; 134 | width: 150px; 135 | border-radius: 20px; 136 | margin-left: 10px; 137 | border: 1px white solid; 138 | } 139 | 140 | .right h4{ 141 | margin-top: 80px; 142 | } 143 | 144 | .right form{ 145 | height: 65vh; 146 | background-color: #342b47; 147 | width: 90vw; 148 | margin: 20px 0 0 10px; 149 | clear: both; 150 | border-radius: 8px; 151 | padding: 30px; 152 | } 153 | 154 | .right form input{ 155 | width: 100%; 156 | border-radius: 6px; 157 | height: 40px; 158 | padding: 8px; 159 | border: none; 160 | margin-bottom: 10px; 161 | } 162 | 163 | 164 | .right form div{ 165 | width: 100%; 166 | margin-bottom: 10px; 167 | height: 50px; 168 | padding: 30px 10px 0 10px; 169 | } 170 | 171 | } -------------------------------------------------------------------------------- /github-actions-matrix/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Currency-Converter App 11 | 12 | 13 |
14 |
15 |
16 |
17 |

Convert,Complete And Be Convinced

18 |

19 | This App is built using HTML,CSS and Vanilla Javascript,This help to convert any currency and its board rate is up to date 20 |

21 | 22 |
23 |
24 |

Conversion Board

25 |
26 | 27 | 28 |
29 | 30 |
31 | 32 |
33 | 34 |
35 |
36 | 37 |
38 | 39 |
40 | 41 |
42 |
43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /github-actions-matrix/js/index.js: -------------------------------------------------------------------------------- 1 | const inserted = document.getElementById("myinput"); 2 | inserted.addEventListener('input',function(e){ 3 | let converted = e.target.value 4 | let dollarValue = document.getElementById("dollarsid"); 5 | dollarValue.innerHTML = converted * 412.54 6 | let poundValue = document.getElementById("poundsid"); 7 | poundValue.innerHTML = converted * 584.89 8 | let euroValue = document.getElementById("eurosid"); 9 | euroValue.innerHTML = converted *502.97 10 | let cedisValue = document.getElementById("cedisid"); 11 | cedisValue.innerHTML = converted *71.02 12 | }) 13 | 14 | -------------------------------------------------------------------------------- /gitlab-ci/.gitlab-ci.yml: -------------------------------------------------------------------------------- 1 | variables: 2 | IMAGE_NAME: mercybassey/flask-app 3 | IMAGE_TAG: flask-app-1.0 4 | 5 | stages: 6 | - test 7 | - build 8 | - deploy 9 | 10 | run_tests: 11 | stage: test 12 | image: python:3.9-slim-buster 13 | before_script: 14 | - apt-get update 15 | - apt-get install -y python3-dev python3-pip 16 | - pip3 install Flask pytest 17 | script: 18 | - pytest 19 | 20 | build_image: 21 | stage: build 22 | image: docker:20.10.16 23 | services: 24 | - docker:20.10.16-dind 25 | variables: 26 | DOCKER_TLS_CERTDIR: '/certs' 27 | before_script: 28 | - docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD 29 | - docker login registry.gitlab.com -u $GITLAB_USERNAME -p $GITLAB_ACCESS_TOKEN 30 | script: 31 | - docker build -t $IMAGE_NAME:$IMAGE_TAG . 32 | - docker push $IMAGE_NAME:$IMAGE_TAG 33 | - docker build -t registry.gitlab.com/mercybassey683/flask-app . 34 | - docker push registry.gitlab.com/mercybassey683/flask-app 35 | 36 | deploy: 37 | stage: deploy 38 | before_script: 39 | - chmod 400 $DIGITAL_OCEAN_SSH_KEY 40 | script: 41 | - ssh -o StrictHostKeyChecking=no -i $DIGITAL_OCEAN_SSH_KEY root@142.93.231.63 " 42 | docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD && 43 | docker pull $IMAGE_NAME:$IMAGE_TAG && 44 | docker ps -aq | xargs docker stop | xargs docker rm || true && 45 | docker run --detach -p 5000:5000 $IMAGE_NAME:$IMAGE_TAG" 46 | -------------------------------------------------------------------------------- /gitlab-ci/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:3.8-slim-buster 2 | 3 | RUN mkdir /app 4 | 5 | WORKDIR /app 6 | 7 | COPY requirements.txt /app 8 | 9 | RUN pip install -r requirements.txt 10 | 11 | ADD . /app 12 | 13 | EXPOSE 5000 14 | 15 | CMD ["gunicorn", "-b", "0.0.0.0:5000", "wsgi:app"] 16 | -------------------------------------------------------------------------------- /gitlab-ci/app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask 2 | app = Flask(__name__) 3 | 4 | @app.route('/') 5 | def helloworld(): 6 | return 'Hello World!' 7 | -------------------------------------------------------------------------------- /gitlab-ci/requirements.txt: -------------------------------------------------------------------------------- 1 | Flask==2.0.1 2 | pytest==7.1.2 3 | gunicorn==20.1.0 4 | -------------------------------------------------------------------------------- /gitlab-ci/test_app.py: -------------------------------------------------------------------------------- 1 | from app import app 2 | 3 | def test_main(): 4 | # Creates a test client for this application. 5 | response = app.test_client().get('/') 6 | 7 | # assert the stutus code of the page('/') is 200 8 | assert response.status_code == 200 9 | # assert the return statement to the page 10 | assert response.data == b'Hello World!' 11 | -------------------------------------------------------------------------------- /gitlab-ci/wsgi.py: -------------------------------------------------------------------------------- 1 | from app import app as application 2 | app = application -------------------------------------------------------------------------------- /how-to-build-a-solid-ansible-playbook/lemp_ubuntu1804/files/info.php.j2: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /power-bi-python/central.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from numpy import product 3 | # Importing the invoice fetching API function from invoices.py 4 | from invoices import call_invoices 5 | import asyncio 6 | import time 7 | import schedule 8 | from apscheduler.schedulers.asyncio import AsyncIOScheduler 9 | from datetime import datetime 10 | import os 11 | 12 | # Creating the main function 13 | async def chain(): 14 | def _handle_task_result(task: asyncio.Task) -> None: 15 | try: 16 | task.result() 17 | except asyncio.CancelledError: 18 | pass 19 | except Exception: 20 | logging.exception('Exception raised by task %r',task) 21 | start = time.perf_counter() 22 | # Creating task for the imported function from invoices.py 23 | invoice_task = asyncio.create_task(call_invoices()) 24 | 25 | # Awaiting the task created 26 | await invoice_task 27 | # Keeping track of the task's times 28 | end = time.perf_counter()-start 29 | l_time = time.localtime() 30 | human_time = time.asctime(l_time) 31 | print (f"chained result took {end:0.2f} seconds") 32 | print(f"Current time is {human_time}") 33 | 34 | if name == "main": 35 | # Scheduler enables the code to loop forever and take sleep breaks between the loops. 36 | scheduler = AsyncIOScheduler() 37 | scheduler.add_job(chain,'interval',seconds=1) 38 | scheduler.start() 39 | print('Press Ctrl+{0} to exit'.format('Break' if os.name == 'nt' else 'C')) 40 | 41 | try: 42 | asyncio.get_event_loop().run_forever() 43 | except (KeyboardInterrupt,SystemExit): 44 | pass -------------------------------------------------------------------------------- /power-bi-python/invoices.py: -------------------------------------------------------------------------------- 1 | # Importing essential modules 2 | import pymysql 3 | from pandas.core.frame import DataFrame 4 | import requests 5 | import pandas as pd 6 | from requests.api import get 7 | from sqlalchemy.dialects.mysql import LONGTEXT 8 | 9 | import os 10 | import schedule 11 | import time 12 | import asyncio 13 | 14 | # Importing the connection string from connection.py 15 | from connection import engine 16 | 17 | # Defining request parameters. 18 | headers = { 19 | 'accept':'application/json', 20 | 'authorization':'Bearer *Your-bearer-code if the authentication is Bearer*' 21 | } 22 | baseurl = 'https://*your base url*' 23 | endpoint = 'your endpoint' 24 | 25 | # Wrap the code with an async function to make it asynchronous. 26 | async def get_invoices(): 27 | print("Going through the invoices") 28 | def main_request(baseurl,endpoint,x,headers): 29 | # Using request's get method to pull data using defined parameters. 30 | # Using f string to iterate pages when the function is called. 31 | r = requests.get(baseurl + endpoint + f'?page={x}',headers=headers) 32 | return r.json() 33 | 34 | def get_pages(response): 35 | return response['meta']['total_pages'] 36 | 37 | def parse_json(response): 38 | charlist =[] 39 | for item in response['invoices']: 40 | charlist.append(item) 41 | return charlist 42 | 43 | # Calling the main function with pre-defined parameters. 44 | data = main_request(baseurl=baseurl,endpoint=endpoint,x=1,headers=headers) 45 | 46 | main_invoices = [] 47 | # Iterating/paginating through API data. 48 | # Your API provider might be using a different 49 | # Method for paginating. 50 | for x in range(1,get_pages(data)+1): 51 | print(x) 52 | main_invoices.extend(parse_json(main_request(baseurl,endpoint,x,headers))) 53 | df_invoices = pd.DataFrame(main_invoices) 54 | 55 | # Write new data to sql database. 56 | # Note: Ensure the database's table name matches the table name provided here. 57 | df_invoices.to_sql('invoices',con=engine,if_exists='replace',index=False) 58 | 59 | # This function awaits the get_invoices function, 60 | # runs the get_invoices() function when called, 61 | # and will be called by an external file to envoke your API call. 62 | async def call_invoices(): 63 | await get_invoices() -------------------------------------------------------------------------------- /psreadline/SamplePredictor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net6.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /psreadline/SamplePredictorClass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using System.Management.Automation; 5 | using System.Management.Automation.Subsystem; 6 | using System.Management.Automation.Subsystem.Prediction; 7 | 8 | namespace PowerShell.Sample 9 | { 10 | public class SamplePredictor : ICommandPredictor 11 | { 12 | private readonly Guid _guid; 13 | 14 | internal SamplePredictor(string guid) 15 | { 16 | _guid = new Guid(guid); 17 | } 18 | 19 | /// 20 | /// Gets the unique identifier for a subsystem implementation. 21 | /// 22 | public Guid Id => _guid; 23 | 24 | /// 25 | /// Gets the name of a subsystem implementation. 26 | /// 27 | public string Name => "SamplePredictor"; 28 | 29 | /// 30 | /// Gets the description of a subsystem implementation. 31 | /// 32 | public string Description => "A sample predictor"; 33 | 34 | /// 35 | /// Get the predictive suggestions. It indicates the start of a suggestion rendering session. 36 | /// 37 | /// Represents the client that initiates the call. 38 | /// The object to be used for prediction. 39 | /// The cancellation token to cancel the prediction. 40 | /// An instance of . 41 | public SuggestionPackage GetSuggestion(PredictionClient client, PredictionContext context, CancellationToken cancellationToken) 42 | { 43 | string input = context.InputAst.Extent.Text; 44 | if (string.IsNullOrWhiteSpace(input)) 45 | { 46 | return default; 47 | } 48 | 49 | return new SuggestionPackage(new List{ 50 | new PredictiveSuggestion(string.Concat(input, " HELLO WORLD")) 51 | }); 52 | } 53 | 54 | #region "interface methods for processing feedback" 55 | 56 | /// 57 | /// Gets a value indicating whether the predictor accepts a specific kind of feedback. 58 | /// 59 | /// Represents the client that initiates the call. 60 | /// A specific type of feedback. 61 | /// True or false, to indicate whether the specific feedback is accepted. 62 | public bool CanAcceptFeedback(PredictionClient client, PredictorFeedbackKind feedback) => false; 63 | 64 | /// 65 | /// One or more suggestions provided by the predictor were displayed to the user. 66 | /// 67 | /// Represents the client that initiates the call. 68 | /// The mini-session where the displayed suggestions came from. 69 | /// 70 | /// When the value is greater than 0, it's the number of displayed suggestions from the list 71 | /// returned in , starting from the index 0. When the value is 72 | /// less than or equal to 0, it means a single suggestion from the list got displayed, and 73 | /// the index is the absolute value. 74 | /// 75 | public void OnSuggestionDisplayed(PredictionClient client, uint session, int countOrIndex) { } 76 | 77 | /// 78 | /// The suggestion provided by the predictor was accepted. 79 | /// 80 | /// Represents the client that initiates the call. 81 | /// Represents the mini-session where the accepted suggestion came from. 82 | /// The accepted suggestion text. 83 | public void OnSuggestionAccepted(PredictionClient client, uint session, string acceptedSuggestion) { } 84 | 85 | /// 86 | /// A command line was accepted to execute. 87 | /// The predictor can start processing early as needed with the latest history. 88 | /// 89 | /// Represents the client that initiates the call. 90 | /// History command lines provided as references for prediction. 91 | public void OnCommandLineAccepted(PredictionClient client, IReadOnlyList history) { } 92 | 93 | /// 94 | /// A command line was done execution. 95 | /// 96 | /// Represents the client that initiates the call. 97 | /// The last accepted command line. 98 | /// Shows whether the execution was successful. 99 | public void OnCommandLineExecuted(PredictionClient client, string commandLine, bool success) { } 100 | 101 | #endregion; 102 | } 103 | 104 | /// 105 | /// Register the predictor on module loading and unregister it on module un-loading. 106 | /// 107 | public class Init : IModuleAssemblyInitializer, IModuleAssemblyCleanup 108 | { 109 | private const string Identifier = "843b51d0-55c8-4c1a-8116-f0728d419306"; 110 | 111 | /// 112 | /// Gets called when assembly is loaded. 113 | /// 114 | public void OnImport() 115 | { 116 | var predictor = new SamplePredictor(Identifier); 117 | SubsystemManager.RegisterSubsystem(SubsystemKind.CommandPredictor, predictor); 118 | } 119 | 120 | /// 121 | /// Gets called when the binary module is unloaded. 122 | /// 123 | public void OnRemove(PSModuleInfo psModuleInfo) 124 | { 125 | SubsystemManager.UnregisterSubsystem(SubsystemKind.CommandPredictor, new Guid(Identifier)); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /python-url-shortner/.gitignore: -------------------------------------------------------------------------------- 1 | .env 2 | __pycache__ 3 | .idea 4 | -------------------------------------------------------------------------------- /python-url-shortner/appspec.yml: -------------------------------------------------------------------------------- 1 | # The deployment version, with a default value of 0.0, CodeDeploy will automatically increment this value on each successful deployment 2 | version: 0.0 3 | 4 | # The operating system running on the target compute resource. 5 | # For EC2 instances using Ubuntu, RHEL, or Linux Amazon Machine Images (AMI) use Linux as the value. 6 | os: linux 7 | 8 | # A list of files to copy on each deployment. 9 | files: 10 | # A directory to copy in each application revision, if only a "/" is used for the source, all files in that directory are copied. 11 | - source: / 12 | destination: /app 13 | 14 | # The "hooks" section defines the scripts to be run on each Lifecycle event. 15 | # The hook events are run in the following order: "BeforeInstall", "ApplicationStop", "ApplicationStart", "ValidateService" 16 | hooks: 17 | # Prior to installation steps, run the following actions. 18 | BeforeInstall: 19 | # The location for the "install_docker.sh" script to install Docker and docker-compose. 20 | - location: install_docker.sh 21 | # Run the CodeDploy agent with root permissions. 22 | runas: root 23 | 24 | # Run the lifecycle event to stop the application via the defined script. 25 | ApplicationStop: 26 | - location: stop.sh 27 | timeout: 2000 28 | runas: root 29 | 30 | # Run the lifecycle event to start the application via the defined script. 31 | ApplicationStart: 32 | - location: start.sh 33 | timeout: 3600 34 | runas: root -------------------------------------------------------------------------------- /python-url-shortner/codedeploy-files/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM python:alpine as python 2 | 3 | ENV VIRTUAL_ENV=/opt/venv 4 | RUN python3 -m venv $VIRTUAL_ENV 5 | ENV PATH="$VIRTUAL_ENV/bin:$PATH" 6 | 7 | COPY requirements.txt requirements.txt 8 | RUN pip install -r requirements.txt 9 | 10 | WORKDIR /url 11 | 12 | COPY . . 13 | -------------------------------------------------------------------------------- /python-url-shortner/codedeploy-files/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | database: 4 | image: docker.io/bitnami/mongodb:latest 5 | ports: 6 | - '27017:27017' 7 | volumes: 8 | - 'mongodb_data:/bitnami/mongodb' 9 | 10 | api: 11 | depends_on: 12 | - database 13 | build: 14 | target: python 15 | context: . 16 | environment: 17 | - MONGO_URI=mongodb://database:27017 18 | command: uvicorn routes:app --host 0.0.0.0 19 | ports: 20 | - "8000:8000" 21 | 22 | volumes: 23 | mongodb_data: 24 | driver: local -------------------------------------------------------------------------------- /python-url-shortner/codedeploy-files/requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.4.1 2 | click==8.0.1 3 | dnspython==1.16.0 4 | fastapi==0.68.0 5 | h11==0.12.0 6 | pydantic==1.8.2 7 | pymongo==3.12.0 8 | shortuuid==1.0.1 9 | starlette==0.14.2 10 | typing-extensions==3.10.0.0 11 | uvicorn==0.14.0 12 | -------------------------------------------------------------------------------- /python-url-shortner/codedeploy-files/routes.py: -------------------------------------------------------------------------------- 1 | from fastapi import FastAPI, Response, status, Request 2 | from fastapi.responses import RedirectResponse 3 | from pymongo import MongoClient 4 | from pydantic import BaseModel 5 | import datetime 6 | import shortuuid 7 | import os 8 | 9 | app = FastAPI() 10 | client = MongoClient(os.environ.get('MONGO_URI')) 11 | url_collection = client['ata-url-app'] 12 | 13 | # Retrieve long_url from database and redirect to long_url 14 | @app.get("/detail") 15 | async def detail(): 16 | return {"message":"REST API for generating short URLs"} 17 | 18 | 19 | # Retrieve long_url from database and redirect to long_url 20 | @app.get("/{short_url_id}") 21 | async def root(response: Response, request: Request): 22 | short_url_id = request.url.path.split('/')[1] 23 | 24 | data = url_collection.urls.find_one({"url_id": short_url_id}) 25 | 26 | if data is None: 27 | response.status_code = status.HTTP_404_NOT_FOUND 28 | return {'message': 'Url for {} not found'.format(data)} 29 | 30 | return RedirectResponse(data['long_url']) 31 | 32 | 33 | class UrlModel(BaseModel): 34 | url: str 35 | 36 | 37 | # Insert long_url to database 38 | @app.post("/shorty") 39 | def url(url: UrlModel, response: Response): 40 | print(url) 41 | if url is not None and type(url.url) == str: 42 | url_id = shortuuid.uuid() 43 | short_url = "http://localhost:8000/{0}".format(url_id) 44 | 45 | data = { 46 | "long_url": url.url, 47 | "short_url": short_url, 48 | "dateCreated": datetime.datetime.now(), 49 | "url_id": url_id 50 | } 51 | 52 | url_collection.urls.insert_one(data) 53 | 54 | return {"short_url": short_url} 55 | 56 | response.status_code = status.HTTP_422_UNPROCESSABLE_ENTITY 57 | return {'message': 'No valid url in request body'} 58 | -------------------------------------------------------------------------------- /python-url-shortner/install_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Update container Linux image APT repository data 4 | apt-get update 5 | 6 | # Install Docker required packages 7 | apt-get -y install apt-transport-https ca-certificates lsb-release 8 | 9 | # Add the Docker GPG key to trust the Docker APT repository 10 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 11 | 12 | echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null 13 | 14 | # Update container Linux image APT repository data again after adding the Docker repository 15 | apt-get update 16 | 17 | # Install the Docker community edition and cli 18 | apt-get -y install docker-ce docker-ce-cli containerd.io 19 | 20 | # Download docker-compose executable file, replace the 1.29.2 listed below with the latest version you intend to use. 21 | curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose 22 | 23 | # Change permission of docker-compose to become executable 24 | chmod +x /usr/local/bin/docker-compose -------------------------------------------------------------------------------- /python-url-shortner/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker-compose up --build -------------------------------------------------------------------------------- /python-url-shortner/stop.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | docker-compose down -------------------------------------------------------------------------------- /python-zip/all_black.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/python-zip/all_black.bmp -------------------------------------------------------------------------------- /python-zip/all_blue.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/python-zip/all_blue.bmp -------------------------------------------------------------------------------- /python-zip/all_green.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/python-zip/all_green.bmp -------------------------------------------------------------------------------- /python-zip/all_red.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/python-zip/all_red.bmp -------------------------------------------------------------------------------- /python-zip/demo.py: -------------------------------------------------------------------------------- 1 | from types import MethodDescriptorType 2 | import zipfile # imports the zipfile module so you can make use of it 3 | import shutil # imports the shutil module 4 | import os # for manipulating directories 5 | from os.path import basename # for deleting any prefix up to the last slash character of a pathname 6 | 7 | def zip_files(destination_file, list_of_files, compress=zipfile.ZIP_DEFLATED): # it will now compresses by default 8 | # create ZipFile object in "w"ritemode, storing the reference in the new_zip object 9 | with zipfile.ZipFile(destination_file, mode="w", compression=compress) as new_zip: 10 | # the function parameter destination_file is passed as an argument to the constructor 11 | # the end result is that destination_file is the filename of the destination zip file 12 | # compress will dictate the compression used when creating the ZipFile object 13 | for file in list_of_files: 14 | # goes through every file in the list_of_files - received as a function parameter 15 | new_zip.write(file) # the file you want add to the zip file 16 | 17 | def list_zip_file_contents(source_file): # the function receives the name of an existing file 18 | # Read source_file which is an already existing zip file 19 | with zipfile.ZipFile(source_file, mode="r") as source: 20 | # prints the name of the existing zip file 21 | print(source_file) 22 | # Get list of files names in zip 23 | file_names = source.namelist() 24 | # Iterate over the list of file names print them 25 | for file_name in file_names: 26 | # prints the name of files within, with a tab for better readability 27 | print("\t", file_name) 28 | 29 | def add_files_to_zip_file(destination_file, list_of_files): 30 | # create ZipFile object in "a"ppend mode in order to add content to the file 31 | with zipfile.ZipFile(destination_file, mode="a") as new_zip: 32 | # the files will be added to the destination_file 33 | for file in list_of_files: 34 | # goes through every file in the list_of_files 35 | new_zip.write(file) # the file you want add to the zip file 36 | 37 | def unzip_files_with_zipfile(source_file, destination_folder, files_to_extract): 38 | with zipfile.ZipFile(source_file, mode="r") as source: 39 | if files_to_extract: 40 | for file in files_to_extract: 41 | source.extract(file, path=destination_folder) 42 | else: 43 | source.extractall(path=destination_folder) 44 | 45 | def unzip_files_with_shutil(source_file, destination_folder): 46 | shutil.unpack_archive(source_file, destination_folder) 47 | 48 | def filter_and_zip_files(destination_file, list_of_files, filter): 49 | print ("hello") 50 | 51 | # zip the files from given directory that matches the filter 52 | def filter_and_zip_files (destination_file, source_foulder, filter): 53 | with zipfile.ZipFile(destination_file, mode="w", compression=zipfile.ZIP_DEFLATED) as new_zip: 54 | # Iterate over all the files in the folder 55 | test = os.walk(source_foulder) 56 | for folder, subfolders, filenames in os.walk(source_foulder): 57 | for filename in filenames: 58 | if filter(filename): 59 | # create complete filepath of file in directory 60 | file_path = os.path.join(folder, filename) 61 | # Add file to zip 62 | new_zip.write(file_path, basename(file_path)) 63 | 64 | # unzip only files withtin the zip file that match the filter 65 | def unzip_filtered_files (source_file, destination_folder, filter): 66 | with zipfile.ZipFile(source_file, "r") as source: 67 | list_of_file_names = source.namelist() # you'll get an iterable object 68 | for file_name in list_of_file_names: 69 | # checks if the file matches the filter ls 70 | 71 | if filter(file_name): 72 | # Extract the files to destination_folder 73 | source.extract(file_name,path=destination_folder ) 74 | 75 | # zipping a single file 76 | zip_files("single_file.zip", ["all_black.bmp"]) 77 | 78 | # zipping multiple files 79 | zip_files("multiple_files.zip", ["all_blue.bmp","all_green.bmp", "all_red.bmp"]) 80 | 81 | # zipping and compressing multiple files 82 | zip_files("multiple_files_uncompressed.zip", ["all_blue.bmp","all_green.bmp", "all_red.bmp"], zipfile.ZIP_STORED) 83 | 84 | # listing the contents of existing zip file 85 | list_zip_file_contents("multiple_files.zip") 86 | 87 | print("adding all_black.bmp to multiple_files.zip") 88 | # adding all_black.bmp to the multiple_files.zip 89 | add_files_to_zip_file("multiple_files.zip", ["all_black.bmp"]) 90 | 91 | # listing the contents of existing zip file 92 | list_zip_file_contents("multiple_files.zip") 93 | 94 | # unzipping all files to the folder all_colors 95 | unzip_files_with_zipfile("multiple_files.zip", "all_colors", []) 96 | 97 | # unzipping only colors that start with b to only_b_colors 98 | unzip_files_with_zipfile("multiple_files.zip", "only_b_colors", ["all_black.bmp", "all_blue.bmp"]) 99 | 100 | # unzipping all colors with shutil 101 | unzip_files_with_shutil("multiple_files.zip", "shutil_extraction") 102 | 103 | # zipping only colors that start with b to only_b_colors by using_filters 104 | filter_and_zip_files("only_b_colors.zip", ".", lambda name : name.startswith("all_b")) 105 | list_zip_file_contents("only_b_colors.zip") 106 | 107 | # unzipping only colors that start with b to only_b_colors by using_filters 108 | unzip_filtered_files("multiple_files.zip", "not_b_colors", lambda name : not name.startswith("all_b")) -------------------------------------------------------------------------------- /sample_cert_files.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Adam-the-Automator/Scripts/8668e82a28a6a2a57ba78a9739e304b46f3c511b/sample_cert_files.zip --------------------------------------------------------------------------------