Skip to content

Instantly share code, notes, and snippets.

View adamori's full-sized avatar
🫠

Adam Alidibirov adamori

🫠
View GitHub Profile
@adamori
adamori / powershellevents.ps1
Last active December 26, 2022 01:01
PowerShell script to dump system events data to a file. User can enter start date, end date and the filename where will be saved data. Youtube Link: https://youtu.be/BPsEyuElf-Y
# Prompt user to input start date, end date, and file name
# If no value is provided, use default values
if (!($startDate = Read-Host "Enter the start date (yyyy-mm-dd) [2022-12-01]")) { $startDate = "2022-12-01" }
if (!($endDate = Read-Host "Enter the end date (yyyy-mm-dd) [2022-12-31]")) { $endDate = "2022-12-31" }
if (!($fileName = Read-Host "Enter the file name [output.txt]")) { $fileName = "output.txt" }
$startTimeXPath = (Get-Date $startDate).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffffffZ')
$endTimeXPath = (Get-Date $endDate).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss.fffffffZ')
# Set filters to retrieve events with Level 1 or 2 severity from specified date range
@adamori
adamori / vbs_script_count_words_of_file.vbs
Created December 25, 2022 20:49
You can use it by command: `cscript script.vbs jerome.txt 10` jerome.txt - is file with text, 10 - is top words, script.vbs - name of this script
' See Visual Basic'i skript loeb käsurea argumendina määratud tekstifaili ning töötleb teksti,
' et leida ja loendada failis kõige populaarsemad sõnad. Skript loob kõigepealt regulaaravaldise objekti,
' mida kasutatakse tekstis olevate üksikute sõnade tuvastamiseks. Seejärel itereerib ta teksti läbi, lisades iga sõna sõnastikuobjektile,
' mis salvestab iga sõna arvu. Kui kõik sõnad on töödeldud, sorteerib skript sõnastiku sõnade arvu alusel kahanevas järjekorras ja
' väljastab N kõige populaarsemat sõna, kus N on määratud teise käsurea argumendina.
' Seejärel teostab skript sarnase protsessi, et leida ja loendada sõnu, mis sisaldavad apostrofe.
' Ta kasutab nende sõnade tuvastamiseks teistsugust regulaaravaldist ning loendab ja sorteerib neid samamoodi nagu eelmises etapis.
' Lõpuks väljastab skript failis olevate sõnade koguarvu ja unikaalsete sõnade arvu.
@adamori
adamori / filesorting.vbs
Created December 25, 2022 21:06
This script moves and organizes JPEG/JPG files into subdirectories based on the date they were created, and displays a summary of the moved files.
' Set the locale to US English
SetLocale(1033)
Set objArgs = WScript.Arguments
' Check if the number of arguments passed to the script is less than or equal to 1
' If no arguments were passed, display a message and quit the script
If objArgs.Count <= 1 Then
Wscript.Echo "Enter directory of pictures and target directory"
WScript.Quit 1
@adamori
adamori / convert.bat
Created December 25, 2022 21:44
This code is a batch script that converts Estonian characters in a string to HTML code and counts the number of Estonian characters. It takes a single argument as input, which should be the string to be processed, and outputs the converted string and the character counts.
@echo off
setlocal enabledelayedexpansion
:: Set character encoding to UTF-8 to support Estonian characters
@chcp 65001
:: Check if argument was provided
if "%~1" == "" ( echo No arguments... & exit /b )
:: Set string and initialize variables
set str=%1
@adamori
adamori / pdfemailsender.ps1
Last active December 25, 2022 23:57
This script regularly checks a specified folder for new PDF files, extracts certain data from them, and sends the PDF files to a specified email address with the extracted data included in the subject and body of the email message. https://youtu.be/UnhiEivi0J0
# Set the email server and login credentials
$smtpServer = "smtp.gmail.com"
$username = "[email protected]"
$password = "password"
$sendTo = "[email protected]"
# Create a PSCredential object using the login credentials
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username, $(ConvertTo-SecureString -String $password -AsPlainText -Force)
print(f"Enter 'exit' to close")
while(True):
text = input("Enter your promt: ")
if text == 'exit':
exit()
words = text.split()
num_words = len(words)
num_dots = text.count(".")
import os
import sys
import traceback
from collections import namedtuple
from pathlib import Path
import re
import torch
import torch.hub
import datetime
import os
import pandas as pd
import ijson
# Get a list of all JSON files in the current directory
json_files = [f for f in os.listdir('.') if f.endswith('.json')]
# If there are no JSON files, print an error message and exit
if not json_files:
@adamori
adamori / assignment_1.md
Created March 7, 2023 13:01
Разработать функцию, реализующую логическую операцию «штрих Шеффера». С ее помощью построить таблицу истинности для этой операции.
def schaeffers_stroke(a, b):
    return not (a and b)
a b f
0 0 1
0 1 1
1 0 1
@adamori
adamori / Pierce Arrow.md
Last active March 7, 2023 13:10
Разработать функцию, реализующую логическую операцию «стрелка Пирса». С ее помощью построить таблицу истинности для этой операции.
def pierce_arrow(a, b):
  return not(a or b)
a b f
0 0 1
0 1 1
1 0 0