Skip to content

Instantly share code, notes, and snippets.

@sm-g
sm-g / NamingRulesChecker.cs
Created March 20, 2019 07:28
C# editorconfig naming rules checker
public class NamingRulesChecker
{
private const string PrivateConst = " ";
private static readonly double PrivateStaticReadonlyLikeConstant = TimeSpan.FromSeconds(3).Ticks;
private static readonly string[] _privateStaticReadonlyOthers = new[] { "None" };
private static string _privateStatic = "";
public const string PublicConst = "";
public static string PublicStatic = "";
@sm-g
sm-g / DbForeignKeysChecker.cs
Created December 29, 2018 16:41
EF Core InMemory DB foreign keys checker
public static class DbForeignKeysChecker
{
private static readonly Dictionary<DbContext, Dictionary<Type, Keys>> KeysPerEntityTypeOfContext = new Dictionary<DbContext, Dictionary<Type, Keys>>();
public static void SaveChangesWithCheck(this DbContext context)
{
context.SaveChanges();
context.CheckForeignKeys();
}
@sm-g
sm-g / getalltimeactivities.json
Created May 28, 2018 09:26
select * timeactivity with duplicates
{
"QueryResponse": {
"TimeActivity": [{
"TxnDate": "2018-05-09",
"NameOf": "Employee",
"EmployeeRef": {
"value": "260",
"name": "2level_03c0013"
},
"ItemRef": {
// https://stackoverflow.com/questions/15245770/how-to-specify-command-line-options-for-service-in-topshelf/36044058#36044058
/// <param name="argsToSave">
/// If empty, all cli arguments, except added by TopShelf itself, included.
/// If not empty, only arguments starting with string from that array included.
/// </param>
public static void AddCommandLineParametersToStartupOptions(this InstallHostSettings installSettings, IReadOnlyCollection<string> argsToSave = null)
{
var serviceKey = Registry.LocalMachine.OpenSubKey(
$"SYSTEM\\CurrentControlSet\\Services\\{installSettings.ServiceName}",
@sm-g
sm-g / userDefineLang.xml
Created January 27, 2017 11:01
Notepad++ syntax for Serilog logs
<NotepadPlus>
<UserLang name="SerilogLogFile" ext="log" udlVersion="2.1">
<Settings>
<Global caseIgnored="yes" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="0" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">03 04 00 01 02</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@sm-g
sm-g / TileIconify1.diff
Created March 13, 2016 04:36
TileIconify1
From 772de67a9a1eca8f6e6f462a9f9c841ccab3ad10 Mon Sep 17 00:00:00 2001
From: smg <semagerasimov@gmail.com>
Date: Sun, 13 Mar 2016 11:32:45 +0700
Subject: [PATCH] fix EnumerateShortcuts access denied
---
TileIconifier/Forms/frmMain.cs | 47 +++++++++++++++++++++++++++---------------
1 file changed, 30 insertions(+), 17 deletions(-)
diff --git a/TileIconifier/Forms/frmMain.cs b/TileIconifier/Forms/frmMain.cs
diff --git a/src/SolutionCop.DefaultRules/Basic/FilesIncludedIntoProjectRule.cs b/src/SolutionCop.DefaultRules/Basic/FilesIncludedIntoProjectRule.cs
index 54ed67e..c4976d7 100644
--- a/src/SolutionCop.DefaultRules/Basic/FilesIncludedIntoProjectRule.cs
+++ b/src/SolutionCop.DefaultRules/Basic/FilesIncludedIntoProjectRule.cs
@@ -80,6 +80,7 @@ namespace SolutionCop.DefaultRules.Basic
}
foreach (var filePatternToProcess in config.FilePatternsToProcess)
{
+ var projectDirPath = new DirectoryInfo(Path.GetDirectoryName(projectFilePath)).FullName;
var filePaths = Directory.EnumerateFiles(Path.GetDirectoryName(projectFilePath), filePatternToProcess, SearchOption.AllDirectories);
@sm-g
sm-g / gimp
Last active August 29, 2015 14:20
gimp mycrop pattern
(define (mycrop pattern)
(let*
((filelist (cadr (file-glob pattern 1))))
(while (not (null? filelist))
(let*
((filename (car filelist))
(image (car (gimp-file-load RUN-NONINTERACTIVE filename filename)))
(drawable (car (gimp-image-get-active-layer image)))
)
(gimp-image-crop image 608 164 21 301)