Skip to content

Instantly share code, notes, and snippets.

View AlonAm's full-sized avatar

Alon Amsalem AlonAm

View GitHub Profile
@AlonAm
AlonAm / DemoSetup.wixproj
Created August 17, 2019 19:16 — forked from dasMulli/DemoSetup.wixproj
Demo wix project to publish a self-contained .NET Core app
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>3.10</ProductVersion>
<ProjectGuid>91e4dc15-312a-4e90-bc1c-01de5dc99447</ProjectGuid>
<SchemaVersion>2.0</SchemaVersion>
<OutputName>CoreConsoleAppSetup</OutputName>
<OutputType>Package</OutputType>
@AlonAm
AlonAm / SearchAllTables.sql
Created June 24, 2019 07:55
SQL stored procedure for searching text in all tables of a database
CREATE PROC SearchAllTables
(
@SearchStr nvarchar(100)
)
AS
BEGIN
CREATE TABLE #Results (ColumnName nvarchar(370), ColumnValue nvarchar(3630))
SET NOCOUNT ON
@AlonAm
AlonAm / CollectionSynchronizer.cs
Last active June 8, 2019 09:17
Collection Synchronizer
public class CollectionSynchronizer<TSource, TDestination>
{
public Action<TSource> Add { get; set; }
public Action<TDestination> Remove { get; set; }
public Action<TSource, TDestination> Update { get; set; }
public Func<TSource, TDestination, bool> Compare { get; set; }
/// <summary>
/// Synchronize changes from source to destination collection.
/// Source collection is not changed.
using AnyStatus.API;
using System.Threading.Tasks;
public class MyWidgetHealthCheck : ICheckHealth<MyWidget>
{
public async Task Handle(HealthCheckRequest<MyWidget> request, CancellationToken cancellationToken)
{
var myWidget = request.DataContext;
await Task.Delay(1).ConfigureAwait(false);
using AnyStatus.API;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
[DisplayName("My Widget")]
[DisplayColumn("My Category")]
[Description("My widget description.")]
public class MyWidget : Widget, IHealthCheck, ISchedulable, IStartable, IStoppable
{
[Required]
@AlonAm
AlonAm / jekyll-liquid-random-number.html
Created March 12, 2018 19:45 — forked from sweisgerber-dev/jekyll-liquid-random-number.html
Jekyll/Liquid Random number generation hack
<!-- Random ID generation -->
{% assign min = 0 %}
{% assign max = 1000 %}
{% assign diff = max | minus: min %}
{% assign randomNumber = "now" | date: "%N" | modulo: diff | plus: min %}
<!-- /Random ID generation -->
@AlonAm
AlonAm / app.config.xml
Created January 30, 2018 08:48 — forked from yoeun/app.config.xml
NLog settings in app.config and web.config files
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/>
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="default" xsi:type="File"
fileName="C:\logs\app-log.txt"
archiveFileName="C:\logs\archives\app-log.{#}.txt"
@AlonAm
AlonAm / WindowPlacement.cs
Last active September 6, 2022 03:39 — forked from anonymous/WindowPlacement.cs
WPF Window Placement
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows;
using System.Windows.Interop;
using System.Xml;
using System.Xml.Serialization;
namespace WindowPlacementExample
@AlonAm
AlonAm / Pong.cs
Last active May 11, 2018 18:27
AnyStatus Handler
using AnyStatus.API;
using System.Threading.Tasks;
public class MyHealthChecker : ICheckHealth<MyHealthCheck>
{
public async Task Handle(HealthCheckRequest<MyHealthCheck> request, CancellationToken cancellationToken)
{
var myHealthCheck = request.DataContext;
await Task.Delay(1).ConfigureAwait(false);
@AlonAm
AlonAm / Ping.cs
Last active May 11, 2018 18:22
AnyStatus Plugin
using AnyStatus.API;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
[DisplayName("Health Check Example")]
[DisplayColumn("My Category")]
[Description("My health check description.")]
public class MyHealthCheck : Widget, IHealthCheck, IWebPage, ISchedulable, IStartable, IStoppable, IRestartable
{
[Required]