Skip to content

Instantly share code, notes, and snippets.

View janosorcsik's full-sized avatar

János Orcsik janosorcsik

View GitHub Profile
function toHSL(hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
var r = parseInt(result[1], 16);
var g = parseInt(result[2], 16);
var b = parseInt(result[3], 16);
(r /= 255), (g /= 255), (b /= 255);
var max = Math.max(r, g, b),
min = Math.min(r, g, b);
@janosorcsik
janosorcsik / cloudSettings
Last active August 12, 2020 09:24
Visual Studio Code Settings Sync Gist
{"lastUpload":"2020-08-12T09:24:11.113Z","extensionVersion":"v3.4.3"}
@janosorcsik
janosorcsik / launch.json
Last active January 27, 2019 17:26
Launch.json for Electron debuggin in VS Code
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Electron: Main",
"protocol": "inspector",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"runtimeArgs": [
@janosorcsik
janosorcsik / DateTimeCollisionCheck.md
Last active November 20, 2020 20:30
DateTime collision check

Not nullable overlap

(x.StartDate <= y.EndDate && x.EndDate >= y.StartDate)

Nullable overlap

(x.StartDate ?? y.EndDate <= y.EndDate ?? x.StartDate) && (x.EndDate ?? y.StartDate >= y.StartDate ?? x.EndDate)
@janosorcsik
janosorcsik / MethodLocationPatternConverter.cs
Last active December 11, 2017 20:19
log4net extensions
using log4net.Layout.Pattern;
using log4net.Core;
using System.IO;
namespace LoggerExtensions
{
public class MethodLocationPatternConverter : PatternLayoutConverter
{
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
@janosorcsik
janosorcsik / Mapper.cs
Last active December 11, 2017 20:41
Object mapper
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
namespace ObjectExtensions
{
public static class Mapper
{
public static T SetProperty<T>(this T host, string propertyName, object value, bool hideErrors = false)
@janosorcsik
janosorcsik / XMLTools.cs
Last active December 11, 2017 20:49
Generic XML writer and reader with encoding
using System;
using System.IO;
using System.Text;
using System.Xml.Serialization;
namespace Tools
{
public class XMLTools
{
#region singleton
@janosorcsik
janosorcsik / FakeHQContext.cs
Last active December 11, 2017 21:02
Fake Context
using System;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using Entities.HQ;
using Repositories.Contexts;
namespace TestUtils
{
public class FakeHQContext : IHQContext
@janosorcsik
janosorcsik / TestExtensions.cs
Last active December 11, 2017 21:07
Unit test extensions
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Web.App_Start;
@janosorcsik
janosorcsik / FakeDbSet.cs
Last active December 11, 2017 21:07
Fake DbSet
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;