Skip to content

Instantly share code, notes, and snippets.

View melvinlee's full-sized avatar

melvinlee melvinlee

  • Singapore
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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.

netsh http show urlacl

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

@melvinlee
melvinlee / DisposableAction.cs
Created June 30, 2016 02:42
Disposable Action
internal class DisposableAction : IDisposable
{
private readonly Action _action;
public DisposableAction(Action action)
{
_action = action;
}
public void Dispose()
@melvinlee
melvinlee / ExportSQLServerDatabaseRole.sql
Created March 3, 2017 07:06
Script out Database Role Definition
/********************************************************************
* *
* Author: John Eisbrener *
* Script Purpose: Script out Database Role Definition *
* *
********************************************************************/
DECLARE @roleName VARCHAR(255)
SET @roleName = 'DatabaseRoleName'
-- Remove database from Availability Group:
Alter Database [StackExchange.Bicycles.Meta] SET HADR OFF;
-- Apply t-logs to catch up. This can be done manually in SSMS or via:
RESTORE LOG [StackExchange.Bicycles.Meta] FROM DISK = '\\ny-back01\backups\SQL\_Trans\SENetwork_AG\StackExchange.Bicycles.Meta\StackExchange.Bicycles.Meta_LOG_20160217_033201.trn' WITH NORECOVERY;
-- Re-join database to availability group
ALTER DATABASE [StackExchange.Bicycles.Meta] SET HADR AVAILABILITY GROUP = [SENetwork_AG];
ALTER DATABASE [StackExchange.Bicycles.Meta] SET HADR RESUME;