Skip to content

Instantly share code, notes, and snippets.

View mnadjit's full-sized avatar

Mehdi Tehrani mnadjit

  • Melbourne Australia
View GitHub Profile
@mnadjit
mnadjit / load.sh
Created June 18, 2023 13:05
Shell scripts to upload or download contents of the directory passed as arguments
#!/usr/bin/bash
if [ "$#" -eq 0 ]; then
echo $'No paths were passed to the script.\nScript usage:\n> ./load /path/to/dir1 /path/to/dir2'
fi
for path in "$@"
do
echo -e "\n\ngit fetch, reset and pull for path: $path\n"
cd $path
@mnadjit
mnadjit / git_load.ps1
Last active June 18, 2023 13:10
PowerShell scripts to upload or download contents of the directory passed as argument to/from origin
$script:cur_dir = (Get-Location)
$script:args | % {
Set-Location $_
Write-Output "`nDownloading from origin into path: $($_)`n"
git fetch --all
git reset --hard origin/main
git pull --force
}
#!/bin/bash
# Update the repository list of packages
#sudo dnf update -y
#sudo dnf upgrade -y
# uncomment the partner repositories to have access to 3rd party packages
#sudo sed -i 's/# deb http:\/\/archive.canonical.com/deb http:\/\/archive.canonical.com/; s/# deb-src http:\/\/archive.canonical.com/deb-src http:\/\/archive.canonical.com/' /etc/apt/sources.list
# Add RPM Fusion Free Repository
@mnadjit
mnadjit / 00_my_macOS_notes.md
Last active May 3, 2022 07:55
macOS Common commands to get info about a machine, its hardware, status, monitoring, administration and some useful tools.

diskutil list

  • Get a list of all block devices

sudo diskutil mount disk0f1

  • Mount a disk; Name is found in the list obtained using diskutil tool e.g. disk0f1

sudo diskutil unmount disk0f1

  • Unmount a disk

Resize Virtual Disk

Once virtual disk has been resized, the following commands should be run to allow the apfs partitions to expand into the free space. For example if the virtual disk is a Linux qemu disk format i.e. qcow2, after running qemu-img resize MyDisk.qcow2 +20G to expand the file MyDisk.qcow2 by 20 gigabytes, the following commands should be run in Mac terminal. Explained here.

@mnadjit
mnadjit / 00_my_linux_notes.md
Last active May 24, 2022 08:47
Linux Common commands to get info about a machine, its hardware, status, monitoring, administration and some useful tools.
@mnadjit
mnadjit / HL7-MLLP-Broker.py
Last active September 6, 2024 08:19
Simple Python script to open a TCP connection send a test HL7 v2.4 message using MLLP protocol (minimal wrapper)
import socket
from datetime import datetime
import json
import uuid
class Ack:
def __init__(self, msg_str: str):
self.senderApp = msg_str.split('|')[4]
self.senderFac = msg_str.split('|')[5]
self.RecvApp = msg_str.split('|')[2]
@mnadjit
mnadjit / DB_Redis_Basic_Commands.md
Last active June 23, 2021 02:22
Redis basic commands are listed and briefly explained in this document
@mnadjit
mnadjit / DB_Oracle_access.md
Last active January 30, 2023 04:56
Install Oracle Instant-Client on Win10, set up an ODBC connection to an Oracle database, use DBVisualizer to access the database

Oracle Instant Client

Download and install Oracle Instant-Client

  1. From Oracle website
  • Download and unzip the following package: Instant Client Package - Basic
  • Download and unzip the following package: Instant Client Package - ODBC of the same version
  1. In Windows the Basic package has dependency on a certain version of Microsoft Visual Studio Redistributable. Make sure it's installed.
  2. Add files from the ODBC package into the same folder as Basic and that folder would be the installation folder.
  3. Move the installatin folder to a proper location e.g. C:\instantclient or C:\Oracle\instantclient_12_2
  4. Run odbc_install.exe with admin rights and make sure it installs successfully.
  5. Add the installation folder path to PATH environment variable.
@mnadjit
mnadjit / PS_Encrypting_Data.md
Last active January 24, 2022 07:08
PowerShell - Using certificates to encrypt documents or data

Creating the certificate

Pick a domain name which can be anything and also a friendly name

  • $domainName = "me@domain"
  • $friendlyName = "Give it a name"

Create the certificate

  • $cert = New-SelfSignedCertificate -NotAfter (Get-Date).AddYears(2) -DnsName $domainName -CertStoreLocation Cert:\CurrentUser\My -KeyUsage KeyAgreement,KeyEncipherment,DataEncipherment -Type DocumentEncryptionCert -FriendlyName $friendlyName

Create a backup

  • $certThumprint=(Get-ChildItem -Path Cert:\CurrentUser\My\ | Where { $_.FriendlyName -eq $friendlyName }).Thumbprint
  • With Password
    • Export-PfxCertificate -Cert Cert:\CurrentUser\My\$certThumprint -FilePath $env:USERPROFILE\Certificates\MyDocEncCert.pfx -Password (ConvertTo-SecureString -AsPlainText 'password123!' -Force)