Skip to content

Instantly share code, notes, and snippets.

View ObservableExtensions.cs
public static class ObservableExtensions
{
public static IObservable<T1> IsValueUpdated<T1, T2>(this IObservable<T1> source, Func<T1, T1, bool> isVaueUpdatedFunc)
{
return source.Scan(Tuple.Create(default(T1), default(T1)), (prev, current) =>
{
if (isVaueUpdatedFunc(prev.Item2, current))
{
return Tuple.Create(prev.Item2, current);
}
@18konoe
18konoe / Note_WinHttpHandler.SendAsync.cs
Created Feb 1, 2020
Trace HttpClient.PostAsync() to investigate Asyncronouse API implementation
View Note_WinHttpHandler.SendAsync.cs
protected override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request,
CancellationToken cancellationToken)
{
if (request == null)
{
throw new ArgumentNullException(nameof(request), SR.net_http_handler_norequest);
}
View DependencyInjectionDemo.cs
using KonoeStudio.Libs.DependencyInjection;
using KonoeStudio.Libs.DependencyInjection.Interfaces;
namespace KonoeStudio.Demo.DependencyInjection
{
public class Program
{
public static void Main(string[] args)
{
var baseClass = new BaseClass();
View Singleton.cs
public sealed class Singleton
{
private static readonly Lazy<Singleton> Lazy = new Lazy<Singleton>(() => new Singleton());
public static Singleton Instance => Lazy.Value;
private Singleton()
{
}
}
View CloudSpeechGrpcSample.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
View RemoveFiles.ps1
# 実行例
# .\RemoveFiles.ps1 -FolderPath "Hoge\bin\x86\Release -Includes "*.config","*.xml","*.pdb" -Excludes "NLog.config"
# powershell -ExecutionPolicy RemoteSigned -Command .\RemoveFiles.ps1 -FolderPath "Hoge\bin\x86\Release -Includes "*.config","*.xml","*.pdb" -Excludes "NLog.config"
Param(
[parameter(mandatory=$true)][String]$FolderPath,
[parameter(mandatory=$true)][String[]]$Includes,
[parameter(mandatory=$true)][String[]]$Excludes
)
View RegistryValueWatcher.cs
using System;
using System.Management;
using Microsoft.Win32;
namespace Utilities
{
internal class RegistryValueWatcher<T> : ManagementEventWatcher
{
internal RegistryKey Hive { get; private set; }
internal string KeyPath { get; private set; }
@18konoe
18konoe / nginx.service
Created Mar 7, 2018
/lib/systemd/system/nginx.service
View nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
View Import-Firewall-Blocklist-JP.ps1
####################################################################################
#.Synopsis
# Using the Windows Firewall, block all IP addresses listed in a text file.
#
#.Description
# Script will create inbound and outbound rules in the Windows Firewall to
# block all the IPv4 and/or IPv6 addresses listed in an input text file. IP
# address ranges can be defined with CIDR notation (10.4.0.0/16) or with a
# dash (10.4.0.0-10.4.255.255). Comments and blank lines are ignored in the
# input file. The script deletes and recreates the rules each time the
@18konoe
18konoe / BuildCommon.targets
Created Dec 5, 2017
MSBuildでVersionをかえるやつ
View BuildCommon.targets
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="RegexUpdateFile" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Files ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<Regex ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>