Skip to content

Instantly share code, notes, and snippets.

View rkttu's full-sized avatar

Jung Hyun Nam rkttu

View GitHub Profile
@rkttu
rkttu / DelegateInvokeAsyncExtension.cs
Last active June 6, 2023 09:20
Async/Await Alternative Demonstration
using System;
namespace System.Threading.Tasks
{
public static class DelegateInvokeAsyncExtension
{
public static Task<TResult> InvokeAsync<TResult>(
this Func<TResult> function,
AsyncCallback callback = null,
object state = null,
@rkttu
rkttu / iptimeReboot.cs
Last active June 6, 2023 09:20
IPtime router reboot C# application code
// You can compile this code with csc.exe or any C# supported shell.
/*
* Copyright (c) 2016 ClouDeveloper
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software
@rkttu
rkttu / BootstrapDownloader.linq
Created August 15, 2016 11:42
Visual Studio Prerequisites Bootstrap Package Downloader
<Query Kind="Program" />
// https://msdn.microsoft.com/en-us/library/hh873130%28v=vs.140%29.aspx
void Main()
{
MyWebClient webClient = new MyWebClient();
string baseDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "bootstrapDownloads");
if (!Directory.Exists(baseDir)) Directory.CreateDirectory(baseDir);
@rkttu
rkttu / device.js
Last active May 2, 2019 01:38
Azure IoT Hub Device & Service Sample Code
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
'use strict';
var Protocol = require('azure-iot-device-amqp').AmqpWs;
// Uncomment one of these transports and then change it in fromConnectionString to test other transports
// var Protocol = require('azure-iot-device-amqp').AmqpWs;
// var Protocol = require('azure-iot-device-http').Http;
// var Protocol = require('azure-iot-device-mqtt').Mqtt;
using System;
using System.IO;
using System.Threading.Tasks;
// Compatible with .NET Framework 4 Client Profile & legacy C# compiler.
namespace ClouDeveloper
{
public static class FileSystemWatch
{
public const string DefaultFilter =
@rkttu
rkttu / Web API Scratchpad.linq
Created July 7, 2017 17:19
Web API Scratchpad with LINQPad
<Query Kind="Program">
<Connection>
<ID>bea78312-0e65-4c9e-8db4-e64dea24514e</ID>
<Persist>true</Persist>
<Server>(localdb)\hubk</Server>
<Database>PointSaving</Database>
<ShowServer>true</ShowServer>
</Connection>
<NuGetReference>Autofac.WebApi2</NuGetReference>
<NuGetReference>Microsoft.AspNet.WebApi.OwinSelfHost</NuGetReference>
@rkttu
rkttu / WhenUsingAppRepository.cs
Last active July 12, 2017 06:31
MSpec, EF Core 2.0 In-Memory Provider Sample
using TheCompany.Something.Api.Repositories;
using TheCompany.Something.Data;
using TheCompany.Something.Data.Models;
using Machine.Fakes;
using Machine.Specifications;
using Microsoft.EntityFrameworkCore;
using System;
using System.Threading;
using System.Threading.Tasks;
@rkttu
rkttu / ReceiptScanner.cs
Created October 15, 2017 16:48
Receipt Scanner OpenCV C#
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using static OpenCvSharp.Cv2;
using static System.Math;
namespace ReceiptScannerCSharp
{
@rkttu
rkttu / hvswitch.cmd
Created February 14, 2018 05:38
Windows Hypervisor Switch Tool
@echo off
pushd "%~dp0"
cls
echo This script allows you to easily turn on or off Windows Hypervisor settings at once. This script is useful when you want to use Hyper-V or Docker for Windows with other hypervisors.
echo.
net session >nul 2>&1
if not %errorLevel% == 0 (
echo To run this script, you must run it as a user with administrative privileges.
@rkttu
rkttu / dockerd.cmd
Created March 27, 2018 08:43
Run Docker Daemon in WSL Ubuntu
@echo off
pushd "%~dp0"
cls
echo This script allows you to run docker daemon.
echo.
net session >nul 2>&1
if not %errorLevel% == 0 (
echo To run this script, you must run it as a user with administrative privileges.