August 21, 2020
tgit script to use TortoiseGit from command line
https://www.powershellgallery.com/packages/tgit
BTW: it is installed automatically with posh-git powershell module
April 06, 2017
April 05, 2017
March 13, 2017
How to base your branch on different branch
Nice article describing the process
https://makandracards.com/makandra/10173-git-how-to-rebase-your-feature-branch-from-one-branch-to-another
https://makandracards.com/makandra/10173-git-how-to-rebase-your-feature-branch-from-one-branch-to-another
git checkout feature/mybranch
git rebase --onto new_target_branch current_parent_branch
November 30, 2015
Shortcut cheat sheets
Visual studio code - https://code.visualstudio.com/docs/customization/keybindings
Resharper - https://www.jetbrains.com/resharper/docs/ReSharper_DefaultKeymap_VSscheme.pdf
Chrome developer tools - https://developers.google.com/web/tools/chrome-devtools/iterate/inspect-styles/shortcuts
Resharper - https://www.jetbrains.com/resharper/docs/ReSharper_DefaultKeymap_VSscheme.pdf
Chrome developer tools - https://developers.google.com/web/tools/chrome-devtools/iterate/inspect-styles/shortcuts
November 20, 2015
Useful git commands cheat-sheet
git commit --amend -m "New commit message"
git push origin --tags
git push --set-upstream origin name
git branch -u origin/foo - track remote branch
git remote -v - view list of remotes
git remote set-url origin - set remote
git branch -m newname - rename current branch
git push origin master -f - forced push
git rebase master
git checkout master
git merge feature/branch // fast-forward here
git push origin --delete branchname or git push origin :branchname (:branchname should not exist locally then)git
git tag -d name - delete tag locally
git push origin :refs/tags/name - delete tag remotely
git reset --hard HEAD~1 - one commit back
git remote show origin (shows what is in origin and what is stale)
git remote prune origin (removes all local garbage from repo)
git branch -lvv (view list of branches with remotes and marks if remote gone)
git clean -df (remove all untracked files)
git checkout . (discard all the changes to tracked files)
git push origin --tags
git push --set-upstream origin name
git branch -u origin/foo - track remote branch
git remote -v - view list of remotes
git remote set-url origin
git branch -m newname - rename current branch
git push origin master -f - forced push
Rebase branch
git checkout feature/branchgit rebase master
git checkout master
git merge feature/branch // fast-forward here
Cleanup
git branch -D name - delete branch locallygit push origin --delete branchname or git push origin :branchname (:branchname should not exist locally then)git
git tag -d name - delete tag locally
git push origin :refs/tags/name - delete tag remotely
git reset --hard HEAD~1 - one commit back
git remote show origin (shows what is in origin and what is stale)
git remote prune origin (removes all local garbage from repo)
git branch -lvv (view list of branches with remotes and marks if remote gone)
git clean -df (remove all untracked files)
git checkout . (discard all the changes to tracked files)
Code snippet to investigate an object content without dances with debugger in C#
var investigated = ...; // assign your object here System.IO.File.WriteAllText( @"D:\test.json", Newtonsoft.Json.JsonConvert.SerializeObject( investigated, new Newtonsoft.Json.JsonSerializerSettings { Formatting = Newtonsoft.Json.Formatting.Indented, TypeNameHandling = Newtonsoft.Json.TypeNameHandling.Objects }));
November 09, 2015
Rethrow exception and preserve stack trace in.net 4.5
ExceptionDispatchInfo.Capture(myException).Throw();
April 02, 2015
Simplified module loading in powershell
There is a feature for automatic module discorvery in Powershell. It can search for modules based on paths from PsModulePath variable. It is easy to modify it in a script:
$env:PsModulePath += ";$PsScriptRoot/Modules" Import-Module SomeModule -ArgumentList "foo" -Verbose // no need to specify path to the module Get-OtherModuleThing // module will be loaded automatically
August 20, 2012
External program execution handling in Powershell
External command handling in Powershell is quite similar to .cmd-files. For example:
UPD: it is better to use
svn update if ($lastexitcode -ne 0) { throw $lastexitcode }
UPD: it is better to use
throw
in powershell rather than exit
June 29, 2012
Proper script inclusion in PowerShell
It is handy to use simple script inclusion in PowerShell called dot sourcing:
To avoid this, script directory can be used:
UPD: In newer versions script directory variable is provided on the shelf, just use $PsScriptPath variable
. .\include.ps1There is a problem however. If you try to call the script from another directory that script lives in, an error occurs. include.ps1 will not be found since PowerShell uses current folder by default as a starting point.
To avoid this, script directory can be used:
$scriptDirectory = Split-Path -parent $MyInvocation.MyCommand.Definition
. $scriptDirectory\include.ps1
UPD: In newer versions script directory variable is provided on the shelf, just use $PsScriptPath variable
June 20, 2012
External program execution handling in Windows .cmd files
It is common to use .cmd or .bat files to run some simple scheduled tasks. But if you run some external .exe and it reports an error, your script will continue running. So, how to stop execution and exit with error code (usually it is any exit code except 0)? Just write next ugly line after each external program execution:
if %errorlevel% neq 0 exit /b %errorlevel%For example:
svn update if %errorlevel% neq 0 exit /b %errorlevel% sqlcmd -S . -i task.sql if %errorlevel% neq 0 exit /b %errorlevel%
June 14, 2012
Explicit datetime
values in SQL server queries
It is common to type some temporary queries by hand in SQL Server Management Studio. In order to filter results by date easy to read datetime format can be used:
select * from Posts where CreationDate > '12 Apr 2012 09:07'Time part can be omitted as well:
select * from Posts where CreationDate > '12 Apr 2012'This format should work in most scenarios since it is difficult for SQL parser to mess with such an obvious date format. Certainly I would not recommend using it in production code.
Subscribe to:
Posts (Atom)