Skip to content

Instantly share code, notes, and snippets.

Andrew Kramarev akramarev

Block or report user

Report or block akramarev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View install-docker.sh
wget -qO- https://get.docker.io/gpg | sudo apt-key add -
sudo sh -c "echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list"
sudo apt-get update
sudo apt-get install lxc-docker
@akramarev
akramarev / new_gist_file.ps1
Last active Jan 29, 2016
Windows disk space, allocation, directories size
View new_gist_file.ps1
Get-ChildItem | Where-Object { $_.PSIsContainer } | ForEach-Object { $_.Name + ": " + "{0:N2}" -f ((Get-ChildItem $_ -Recurse | Measure-Object Length -Sum -ErrorAction SilentlyContinue).Sum / 1MB) + " MB" }
@akramarev
akramarev / update-udp.sql
Created Jun 24, 2017
Update UDT MSSQL User Defined Types
View update-udp.sql
DECLARE @Name NVARCHAR(776) = NULL;
EXEC sys.sp_rename 'dbo.MyUDT', 'zMyUDT';
GO
CREATE TYPE [dbo].[MyUDT] AS TABLE
(
[HierarchyId] [int] NOT NULL
)
GO
View git-on-windows.bat
git config --global core.preloadindex true
git config --global core.fscache true
git config --global gc.auto 256
View kill-sessions.sql
DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), session_id) + ';'
FROM sys.dm_exec_sessions
WHERE
database_id = db_id('DBUser')
AND login_name IN ('DBTest', 'DBServices')
EXEC(@kill);
View git-local-cleanup
git remote prune origin
git branch -vv | grep 'origin/.*: gone]' | awk '{print $1}' | xargs git branch -d
@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')
@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 / 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 / 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
You can’t perform that action at this time.