Skip to content

Instantly share code, notes, and snippets.

View melvinlee's full-sized avatar

melvinlee melvinlee

  • Singapore
View GitHub Profile

netsh http show urlacl

netsh http delete urlacl http://+:80/Reports/

@melvinlee
melvinlee / DeleteRepCommand.sql
Last active May 20, 2021 08:37
Delete SQL Replication command from Distribution Database
-- Identify repl errors
USE [DISTRIBUTOR]
SELECT * FROM MSrepl_errors
ORDER BY time DESC
-- Identify the publisher database id
SELECT * FROM MSpublisher_databases
-- Identify the ID number and command id of the command causing the problem.
-- This will typically show up in the Replication Monitor.
@melvinlee
melvinlee / MainWindow.xaml.cs
Created October 27, 2015 09:35 — forked from joaoportela/MainWindow.xaml.cs
Very simple experiment with C# Tasks and async + await. Do not take any of this code as correct or even as best practice. I'm just trying to understand how this all works. 1st obvious shortcomming: The server only accepts one client connection at a time.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
@melvinlee
melvinlee / Program.cs
Created October 27, 2015 09:34 — forked from jamesmanning/Program.cs
simple TCP client and server
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
@melvinlee
melvinlee / asteriskrealtime.sql
Created October 27, 2015 03:55
Asterisk queue-realtime database schema
CREATE DATABASE IF NOT EXISTS `asteriskrealtime`;
USE `asteriskrealtime`;
/*Table structure for table `queue_log` */
DROP TABLE IF EXISTS `queue_log`;
CREATE TABLE `queue_log` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
@melvinlee
melvinlee / gulpfile.js
Created October 9, 2015 02:24
Gulp configuration using watch, connect and reload.
"use strict";
var gulp = require('gulp');
var connect = require('gulp-connect');
var open = require('gulp-open');
var config = {
port: 8005,
devBaseUr: 'http://localhost',
paths: {
@melvinlee
melvinlee / CsvParser.cs
Last active September 18, 2015 04:00
Helper method to parse csv into type.
public static class CsvParser
{
private static string CheckSpecialChar(string checkChar)
{
return checkChar.Replace("\"", "");
}
public static Collection<UploadExtensionModel> ParseExtension(string fileName)
{
string[] lines;
@melvinlee
melvinlee / ConnectionMapping.cs
Last active September 18, 2015 01:46
Generic Dictionary Mapping Helper
using System.Collections.Generic;
using System.Linq;
namespace Sample
{
public class ConnectionMapping<T>
{
private readonly Dictionary<T, HashSet<string>> _connections =
new Dictionary<T, HashSet<string>>();
@melvinlee
melvinlee / DependencyConfigure.cs
Last active September 10, 2015 10:06
ASP.NET MVC Autofac registration.
internal class DependencyConfigure
{
public static void Initialize()
{
var builder = new ContainerBuilder();
DependencyResolver.SetResolver(new AutofacDependencyResolver(RegisterServices(builder)));
}
private static IContainer RegisterServices(ContainerBuilder builder)
{
@melvinlee
melvinlee / FakeItEasy.cs
Last active September 17, 2015 02:20
Unit test with moq framework
[Test]
public void Run_With_InboxMessages_Should_Call_Repo_Save()
{
//Arrange
var apiConfig = new ApiConfig();
apiConfig.SetCommPort(new CommPort());
var fakeApi = A.Fake<ISmsApi>();
var fakeLogging = A.Fake<ILogging>();
var fakeOutgoingsmsRepo = A.Fake<ISmsOutgoingRepository>();