Skip to content

Instantly share code, notes, and snippets.

@andrijac
andrijac / websockets.cs
Created November 18, 2019 11:13 — forked from davidfowl/websockets.cs
Simple WS ASP.NET Core
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
namespace SimpleWebSockets
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
function stringFormat(format, args) {
if (arguments.length === 0) {
throw "Missing arguments";
}
if (!args) {
return format;
}
return format.replace(/{(\d+)}/g, function(match, number) {
@andrijac
andrijac / load_script_ajax.js
Last active November 11, 2019 21:10 — forked from hagenburger/javascript_loader.js
Dynamically load JavaScript files with callback when finished
atm.loadScript = (function () {
let loadedScripts = [];
return function (src, callback) {
if (~loadedScripts.indexOf(src) && callback) {
callback();
}
$.ajax({
url: src,
@andrijac
andrijac / Ten-Commandments-of-How-to-Write-an-IMAP-client-Mark-Crispin.txt
Created October 28, 2019 13:39
Ten Commandments of How to Write an IMAP client by Mark Crispin
Source: https://www.washington.edu/imap/documentation/commndmt.txt.html
/* ========================================================================
* Copyright 1988-2006 University of Washington
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
powershell -executionpolicy bypass -File .\script.ps1
# https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#without-kubectl-proxy
# Check all possible clusters, as you .KUBECONFIG may have multiple contexts:
kubectl config view -o jsonpath='{"Cluster name\tServer\n"}{range .clusters[*]}{.name}{"\t"}{.cluster.server}{"\n"}{end}'
# Select name of cluster you want to interact with from above output:
export CLUSTER_NAME="some_server_name"
# Point to the API server refering the cluster name
APISERVER=$(kubectl config view -o jsonpath="{.clusters[?(@.name==\"$CLUSTER_NAME\")].cluster.server}")
console.log('Press any key to exit');
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.on('data', process.exit.bind(process, 0));
//https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/async_function #20190526_1018
var timestamp = () => (new Date().getSeconds() + ' ' + new Date().getMilliseconds());
var resolveAfter2Seconds = function() {
console.log("starting slow promise " + timestamp());
return new Promise(resolve => {
setTimeout(function() {
resolve("slow " + timestamp());
console.log("slow promise is done " + timestamp());
}, 5000);
SELECT dest.text,
deqmg.granted_memory_kb,
deqmg.requested_memory_kb,
deqmg.grant_time,
deqmg.query_cost,
deqmg.dop,
deqp.query_plan
FROM sys.dm_exec_query_memory_grants AS deqmg
CROSS APPLY sys.dm_exec_sql_text(deqmg.sql_handle) AS dest
CROSS APPLY sys.dm_exec_query_plan(deqmg.plan_handle) AS deqp;