Skip to content

Instantly share code, notes, and snippets.

@tkirill
tkirill / sm-icontext-explicit-args.cs
Created January 9, 2019 10:52
Possible explicit args for IContext.GetInstance
using System;
using StructureMap;
namespace StructureMapExplicitArgsExample
{
class Soldier
{
private Gun _gun;
public Soldier(Gun gun) => _gun = gun;
}
@tkirill
tkirill / datetime.cs
Created December 16, 2016 07:36
DateTime vs DateTimeOffset
// DateTime NO
var localNow = DateTime.Now;
var oneHourLaterInUtc = localNow.ToUniversalTime().AddHours(1);
oneHourLaterInUtc > localNow
// DateTimeOffset YES
var localNow = DateTimeOffset.Now;
var oneHourLaterInUtc = localNow.ToUniversalTime().AddHours(1);
oneHourLaterInUtc > localNow
Unhandled Exception: Elasticsearch.Net.UnexpectedElasticsearchClientException: Object of type 'Nest.JsonNetSerializer' cannot be converted to type 'Newtonsoft.Json.JsonSerializer'. ---> System.ArgumentException: Object of type 'Nest.JsonNetSerializer' cannot be converted to type 'Newtonsoft.Json.JsonSerializer'.
at System.RuntimeType.TryChangeType(Object value, Binder binder, CultureInfo culture, Boolean needsSpecialCast)
at System.RuntimeType.CheckValue(Object value, Binder binder, CultureInfo culture, BindingFlags invokeAttr)
at System.Reflection.MethodBase.CheckArguments(Object[] parameters, Binder binder, BindingFlags invokeAttr, CultureInfo culture, Signature sig)
at System.Reflection.RuntimeMethodInfo.InvokeArgumentsCheck(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Nest.MultiSearchResponseJsonCon
@tkirill
tkirill / git-reset-test-rig.ps1
Created July 3, 2015 13:12
Test rig for revert git reset
# for http://stackoverflow.com/questions/31207487/recovering-from-git-reset-hard
function Clean-TestRepos {
if (Test-Path test-repo) {
rm -Force -Recurse test-repo
}
}
@tkirill
tkirill / remove-local-branches.ps1
Created July 1, 2015 18:14
Remove local git branches
# For http://stackoverflow.com/q/31026942/458723
# Removes local branches that not exist on any remote
function IsNot-CurrentLocalBranch($branch)
{
return $branch -notmatch "^\*"
}
# For http://stackoverflow.com/q/31026942/458723
function Clean-TestRepos {
if (Test-Path test-repo) {
rm -Force -Recurse test-repo
}
if (Test-Path test-clone) {
rm -Force -Recurse test-clone
@tkirill
tkirill / output.md
Last active August 29, 2015 14:23
Output of git-prune-test.ps1

Full output

Remove remote branches with push
Initialized empty Git repository in C:/Users/t_kirill/workplace/git-prune-test/test-repo/.git/
[master (root-commit) ee2dd44] commit1
    1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file
Switched to a new branch 'branch1'
[branch1 9834b24] commit2

1 file changed, 0 insertions(+), 0 deletions(-)

@tkirill
tkirill / git-fetch-prune-test.ps1
Created June 24, 2015 13:22
Test `git fetch --prune`
# For http://stackoverflow.com/q/31026942/458723
function Clean-TestRepos {
if (Test-Path test-repo) {
rm -Force -Recurse test-repo
}
if (Test-Path test-clone) {
rm -Force -Recurse test-clone
@tkirill
tkirill / jsp-exception
Created June 13, 2015 15:48
JSP PropertyNotFoundException takes freaking 130 lines
[2015-06-13 20:45:04,455] ERROR - jetbrains.buildServer.SERVER - Error javax.el.PropertyNotFoundException: Property 'isFinished' not found on type org.tkirill.teamcity.bisectPlugin.Bisect while processing request: GET '/viewLog.html?buildId=45&buildTypeId=Proj1_Build&tab=bisectBuildTab', from client 127.0.0.1:46547, authenticated as 'admin' {id=1}
javax.el.PropertyNotFoundException: Property 'isFinished' not found on type org.tkirill.teamcity.bisectPlugin.Bisect
at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:290)
at javax.el.BeanELResolver$BeanProperties.access$300(BeanELResolver.java:243)
at javax.el.BeanELResolver.property(BeanELResolver.java:377)
at javax.el.BeanELResolver.getValue(BeanELResolver.java:97)
at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:104)
at org.apache.el.parser.AstValue.getValue(AstValue.java:183)
at org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:184)
at org.apache.jasper.runtime.PageContextImpl.proprietaryEvalu
@tkirill
tkirill / test.ps1
Last active August 29, 2015 14:21
Tests for Remove-MergedGitBranches
# Tests for this PR: https://github.com/dahlbyk/posh-git/pull/159
function Create-EmptyRepo {
if (Test-Path test-repo) {
rm -force -r test-repo
}
git init test-repo
cd test-repo