Skip to content

Instantly share code, notes, and snippets.

Andrew Kramarev akramarev

View GitHub Profile
View sublime-preferences.json
{
"editor_path": "/usr/local/bin/code",
"editor_argument_format": "--goto ${file}:${line}:${col}"
}
@akramarev
akramarev / NunitShortPathFinderApp.cs
Created Jul 11, 2019
[Nunit] Nunit Short Path Finder App. Works in linqpad also.
View NunitShortPathFinderApp.cs
class Program
{
static void Main(string[] args)
{
XDocument xDocument;
using (XmlReader xr = XmlReader.Create(@"c:\Users\akramarev\Downloads\TestResultSet.xml"))
{
xDocument = XDocument.Load(xr);
}
@akramarev
akramarev / get_permissions.sql
Created Jun 22, 2019
[get all mssql permissions grants]
View get_permissions.sql
SELECT
(
dp.state_desc + ' ' +
dp.permission_name collate latin1_general_cs_as +
' ON ' + '[' + s.name + ']' + '.' + '[' + o.name + ']' +
' TO ' + '[' + dpr.name + ']'
) AS GRANT_STMT
FROM sys.database_permissions AS dp
INNER JOIN sys.objects AS o ON dp.major_id=o.object_id
INNER JOIN sys.schemas AS s ON o.schema_id = s.schema_id
@akramarev
akramarev / create.sh
Created Mar 24, 2019
[quickly create new dotnet core test project and run tests] @leetcode
View create.sh
dotnet new nunit
dotnet add package FluentAssertions
dotnet test
@akramarev
akramarev / _.ps1
Created Jan 28, 2019
[how to build Go program for linux on windows]
View _.ps1
# https://stackoverflow.com/questions/20829155/how-to-cross-compile-from-windows-to-linux
$env:GOOS = "linux"
@akramarev
akramarev / _.sh
Created Jan 28, 2019
[pk12 into pem]
View _.sh
# https://stackoverflow.com/questions/15144046/converting-pkcs12-certificate-into-pem-using-openssl
# After that you have:
# - certificate in newfile.crt.pem
# - private key in newfile.key.pem
openssl pkcs12 -in path.p12 -out newfile.crt.pem -clcerts -nokeys
openssl pkcs12 -in path.p12 -out newfile.key.pem -nocerts -nodes
@akramarev
akramarev / readme.md
Last active Jan 22, 2019
[colortool] Change theme for windows consoles
View readme.md

Download tool from here: https://github.com/Microsoft/console/releases, then apply to every console: ps1, cmd, ubuntu

  • ColorTool.exe -b OneHalfDark
  • Right click on the window title to access the ‘Properties’ dialogue box
  • Once the properties dialogue box opens press OK (which saves the color change)
ColorTool.exe -b OneHalfDark
@akramarev
akramarev / Export-Chocolatey.ps1
Created Jan 19, 2019 — forked from alimbada/Export-Chocolatey.ps1
Export installed Chocolatey packages as packages.config - thanks to Matty666
View Export-Chocolatey.ps1
#Put this in Export-Chocolatey.ps1 file and run it:
#Export-Chocolatey.ps1 > packages.config
#You can install the packages using
#choco install packages.config -y
Write-Output "<?xml version=`"1.0`" encoding=`"utf-8`"?>"
Write-Output "<packages>"
choco list -lo -r -y | % { " <package id=`"$($_.SubString(0, $_.IndexOf("|")))`" version=`"$($_.SubString($_.IndexOf("|") + 1))`" />" }
Write-Output "</packages>"
@akramarev
akramarev / git.sh
Last active Jan 26, 2019
[git for wsl] Makes git faster on WSL #wsl #osreinstall
View git.sh
#!/bin/bash
# WSL 'git' wrapper, save as /usr/local/bin/git and chmod a+x
# https://github.com/Microsoft/WSL/issues/981#issuecomment-363638656
REALPATH=`readlink -f ${PWD}`
if [ "${REALPATH:0:5}" == "/mnt/" ]; then
git.exe "$@"
else
/usr/bin/git "$@"
@akramarev
akramarev / sql-progress.sql
Last active Jul 21, 2019
[Print out long running mssql backup/restore queries]
View sql-progress.sql
SELECT session_id as SPID, command, a.text AS Query, start_time, percent_complete, dateadd(second,estimated_completion_time/1000, getdate()) as estimated_completion_time
FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a
WHERE r.command in ('BACKUP DATABASE','BACKUP LOG','RESTORE DATABASE')
You can’t perform that action at this time.