Skip to content

Instantly share code, notes, and snippets.

const fs = require('fs');
function logReqRes(req, res, next) {
const oldWrite = res.write;
const oldEnd = res.end;
const chunks = [];
res.write = (...restArgs) => {
chunks.push(Buffer.from(restArgs[0]));
oldWrite.apply(res, restArgs);
@divsoft
divsoft / CreateZip.cs
Created April 13, 2016 06:43 — forked from anonymous/CreateZip.cs
Extension Method to create a zip from a DirectoryInfo using .NET's System.IO.Compression - ZipArchive
// Extension Method to create a zip from a DirectoryInfo using .NET's System.IO.Compression - ZipArchive
public static class Extensions
{
public static byte[] CreateZip(this DirectoryInfo directory)
{
byte[] result = null;
using (MemoryStream stream = new MemoryStream())
{
using (var archive = new ZipArchive(stream, ZipArchiveMode.Create, true))
{
@divsoft
divsoft / gist:624d44bf59777b1ca1f8e49f753118b6
Created April 13, 2016 06:38
Test Sql Server for address and port
private bool TestForServer(string address, int port)
{
int timeout = 500;
if (ConfigurationManager.AppSettings["RemoteSQLServerTestTimeout"] != null)
int.TryParse(ConfigurationManager.AppSettings["RemoteSQLServerTestTimeout"], out timeout);
var result = false;
try
{
using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp))
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="common">
<section name="logging" type="Common.Logging.ConfigurationSectionHandler, Common.Logging" />
</sectionGroup>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<appSettings>