Skip to content

Instantly share code, notes, and snippets.

@timyhac
timyhac / GetLocalDBNamedPipe.ps1
Last active July 31, 2023 11:06
Get the pipe name for a Local DB instance in powershell
Function GetLocalDBNamedPipe()
{
param( [string]$DB)
# This function can accept instance names in the format '(localdb)\Instance'
$DB = $DB.replace("(localdb)\", '')
# Ensure that it is running (assumes the DB already exists)
# Note: pipe names change each time the database starts
$hshTest | Sort-Object {$_.ServerName} | ForEach-Object {Write-Host `t $_.ServerName `t $_.TimeStamp}
# For Powershell < 4.0
$theHash = ((certutil -hashfile $msodbcsql_Local MD5)[1] -replace '\s','')
# Powershell >= 4 have Get-FileHash
# https://technet.microsoft.com/en-us/library/dn520872(v=wps.630).aspx
$url = "http://mirror.internode.on.net/pub/test/10meg.test"
$output = "10meg.test"
(New-Object System.Net.WebClient).DownloadFile($url, $output)
Get-ChildItem -Filter *.sql | Foreach-Object {
$_.Name
}
# No title
[System.Windows.Forms.MessageBox]::Show("We are proceeding with next step.")
# With title
[System.Windows.Forms.MessageBox]::Show("We are proceeding with next step." , "Status")
# Yes/No
$result = [System.Windows.Forms.MessageBox]::Show('Do you wish to continue', 'Warning', 'YesNo', 'Warning')
if ($result -eq 'Yes') {
# do something
@timyhac
timyhac / concatBuffers.js
Created June 14, 2016 07:27
Javascript concatenate multiple buffers
function concatBuffers() {
var totalSize = 0;
for( let arg of arguments){
totalSize += arg.byteLength;
}
var tmp = new Uint8Array( totalSize );
var runningTotalSize = 0;
var net = require('net');
var serverA = net.createServer();
var serverB = net.createServer();
serverA.on('connection', (socketA) => {
socketA.on('data', (data) => {
console.log('CLIENTA:', data);
});
@timyhac
timyhac / snoopProxy.js
Last active May 2, 2016 05:14
Node-js application that acts as a proxy between a client and a server, logging the traffic to the console
var net = require('net');
HOST = '127.0.0.1'
PORT = 12345
LISTENPORT = 23456
var server = net.createServer( function(socket) {
socket.on('data', function(data){
console.log('CLIENT:', data);