Skip to content

Instantly share code, notes, and snippets.

@vireulgr
vireulgr / Microsoft.PowerShell_profile.ps1
Created December 28, 2018 09:29
My Powershell profile
# my powershell profile
# This profile requres PowerCLI module to be installed
# vmrun -T ws -gu ssadm -gp P@ssw0rd runScriptInGuest $vmss "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "C:\Users\ssadm\Desktop\scripts\updCommon.ps1"
# host time setup
function SetupHostTime {
param( [string]$hostName, [string]$hostDomain, [string]$username, [string]$userpwd )
Connect-ViServer "$hostName.$hostDomain" -User $username -Password $userpwd
$esxcli = Get-EsxCli
@vireulgr
vireulgr / main.cpp
Created May 27, 2019 18:26
Socket server with select
#include "winsock2.h" // C:\Program Files (x86)\Windows Phone Kits\8.0\Include\winsock2.h
#include "ws2tcpip.h" // C:\Program Files (x86)\Windows Phone Kits\8.0\Include\ws2tcpip.h
// C:\Program Files (x86)\Windows Phone Kits\8.0\Include\ws2def.h
#include "..\include\defines.h"
#include "..\util\util.h"
#include <string>
#include <memory>
#include <vector>
function snailWalker(r, c, direction) {
if(direction !== 'inside' && direction !== 'outside') {
return null;
}
if(r < 2 || c < 2) {
return null;
}
let result = Array(c);
# extraction from Marina Mele django tutorial
# source: http://www.marinamele.com/taskbuster-django-tutorial/settings-different-environments-version-control
cd %django_project_dir%
# Requirements
# requirements.txt -> requirements/{dev.txt,production.txt,test.txt,base.txt}
# pip freeze > requirements.txt
mkdir requirements
touch requirements/{dev.txt,production.txt,test.txt,base.txt}
@vireulgr
vireulgr / diffdir.sh
Last active December 14, 2021 16:48
Make a comparison of two directory subtrees. If finds two files with equal subtree path, makes a diff of them.
#!/bin/bash
function usage() { printf "Usage:\r\n$0 <dir 1> <dir 2>"; }
if [[ $# -eq 0 ]]; then
usage
exit
fi
if [[ ! -d $1 ]]; then
@vireulgr
vireulgr / foe_gbg_visualizer.py
Last active September 14, 2022 23:37
Script that plots goods donations to guild by player. Data must be taken from FOE helper CSV export.
import matplotlib.pyplot as plt
import csv
csvFileName = './GBG-export.csv'
################################################################################
class GoodsPerEpochData(object):
def __init__(self, epochName):
self.name = epochName
self.income = 0
@vireulgr
vireulgr / search_for_files_excluding_directory.ps1
Created January 11, 2023 22:21
Powershell script to Search for files recursively excluding particular directory names
gci -recurse -dir | ? FullName -notmatch 'hpcourse|Android_studio|3rdparty|thirdparty' | gci -file -include '*.pro'
@vireulgr
vireulgr / script.js
Last active April 16, 2023 17:01
Wait for JS animation to complete with promises
/// PROMISES EXERCISE
function showCircle(parentEl, cx, cy, radius) {
return new Promise((resolve) => {
const newDiv = document.createElement('div');
newDiv.style.height = '0';
newDiv.style.width = '0';
newDiv.style.left = cx + 'px';
newDiv.style.top = cy + 'px';
newDiv.classList.add('animated-circle')
@vireulgr
vireulgr / index.js
Created July 11, 2023 17:44
Solution for algorithmic problem
/*
Написать функцию, которая принимает в себя массив чисел > 0 и число.
Эта функция должна вернуть массив массивов с числами, которые
являются всеми возможными вариантами сложения чисел,
чтобы получить число, переданное 2м аргументом.
const numbers = [1, 2, 3, 4, 5];
const sum = 3;
const result = findCombinations(numbers, sum);
@vireulgr
vireulgr / opencv_display_image.py
Created January 9, 2024 18:17
How to display images using OpenCV functionality
import cv2
import matplotlib.pyplot as plt
cb_img = cv2.imread("checkerboard_color.png")
coke_img = cv2.imread("coca-cola-logo.png")
# Use matplotlib imshow()
plt.imshow(cb_img)
plt.title("matplotlib imshow")
plt.show()