Skip to content

Instantly share code, notes, and snippets.

@ErgEnn
ErgEnn / PrimitiveConverter.cs
Last active January 27, 2021 19:52
Primitive wrapper for Newtonsoft.Json library. Object Calisthenics suggests, that primitive types should be avoided in code. This JsonConverter allows every primitive to be wrapped in object and unwrapped back into primitive JSON tokens with ease.
public class PrimitiveConverter : JsonConverter
{
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
var token = JToken.FromObject((value as PrimitiveWrapper)._value);
token.WriteTo(writer);
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
@ErgEnn
ErgEnn / git_qf.md
Last active November 26, 2021 09:23
Git quickfixes

Ignore changes without .gitignore:

git update-index --assume-unchanged NAME_OF_FILE_HERE

See log of deleted file

git log --follow -- src/FILENAME

Exit git log

@ErgEnn
ErgEnn / Add-IISSiteBindingsFromCert.ps1
Last active January 3, 2023 12:13
Powershell scripts to create SSL CA and CERT and add them as IIS bindings and add IIS bindings to hosts.txt
# Generates IIS bindings based on certificate
try{
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$arguments = "& '" +$PSCommandPath + "'"
Start-Process powershell -Verb runAs -ArgumentList $arguments
Break
}
@ErgEnn
ErgEnn / disable_win_s_shortcut.reg
Created March 19, 2022 13:45
Disables Win+S hotkey so you can map it to voidtools Everything
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced]
"DisabledHotkeys"="S"
@ErgEnn
ErgEnn / regkeys_to_delete.md
Last active August 8, 2022 08:34
Dism.exe blocked by group policy
HKEY_LOCAL_MACHINE\Software\Policies\Microsoft
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Group Policy
HKEY_CURRENT_USER\Software\Policies\Microsoft
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Group Policy
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies
@ErgEnn
ErgEnn / random_EE_LT_personal_code.js
Created September 2, 2022 13:31
Personal code generators
function getControlNumber(code) {
var multiplier1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 1],
multiplier2 = [3, 4, 5, 6, 7, 8, 9, 1, 2, 3],
mod,
total = 0;
for (var i = 0; i < 10; i++) {
total += code.charAt(i) * multiplier1[i];
}
mod = total % 11;
@ErgEnn
ErgEnn / ConvertNewFiles.ps1
Last active September 13, 2022 18:25
Due to many video files being in awkward encoding, they can't be easily copied from one site and pasted to another. This script monitors a folder and whenever new file appears, it runs it through ffmpeg and opens the explorer with new file selected
$folder = 'D:\Ergo\Videos\convert_queue'
$filter = '*.*'
$fsw = New-Object IO.FileSystemWatcher $folder, $filter
$fsw.IncludeSubdirectories = $false
$fsw.NotifyFilter = [IO.NotifyFilters]'FileName, LastWrite'
$a = Register-ObjectEvent $fsw Created -SourceIdentifier FileCreated
while($true) {
$vnt = Wait-Event -SourceIdentifier FileCreated
$name = $vnt.SourceEventArgs.Name
$path = $vnt.SourceEventArgs.FullPath
@ErgEnn
ErgEnn / jiraTogglTotalTime.user.js
Last active January 27, 2023 11:29
Shows total time of Jira ticket based on Toggl(client side only).
// ==UserScript==
// @name JiraTogglTotalTime
// @namespace https://gist.github.com/ErgEnn/6fd34add5aa1d6bfdd0f1b634b93a77e
// @version 0.3
// @description Shows total time of Jira ticket based on Toggl(client side only). Requires Toggl task descr to contain the ticket key.
// @author Ergo Enn
// @match https://*/browse*
// @match https://*/jira/software*
// @icon https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
@ErgEnn
ErgEnn / JiraCopyBranchName.user.js
Last active October 25, 2022 13:23
Removes the GIT CLI command for branch creation from Create Branch menu for easier copying
// ==UserScript==
// @name JiraCopyBranchName
// @namespace
// @version 0.1
// @description Removes the GIT CLI command for branch creation from Create Branch menu for easier copying
// @author Ergo Enn
// @match https://*/browse*
// @match https://*/jira/software*
// @icon https://www.google.com/s2/favicons?sz=64&domain=atlassian.net
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
# recursively run docker-compose on all docker-compose.yml
dir -recurse -include docker-compose.yml | Foreach {docker-compose --file $_.fullName down}