Skip to content

Instantly share code, notes, and snippets.

@yizhang82
yizhang82 / aspnetcore-2.0-windowsservercore-1709
Last active April 13, 2018 00:35
Asp.NET core runtime environment on Windows Server Core 1709 on .NET Core 2.0.6 runtime
# escape=`
# Installer image
FROM microsoft/windowsservercore:1709 AS installer-env
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Retrieve the runtime store
RUN @('2.0.0', '2.0.3', '2.0.5', '2.0.6') | % { `
$downloadUrl = \"https://dist.asp.net/runtimestore/${_}/win-x64/aspnetcore.runtimestore.zip\"; `
@yizhang82
yizhang82 / dotnet-2.0.6-windowsservercore-1709
Last active April 12, 2018 23:41
Dotnet 2.0.6 runtime image on Windows Server Core 1709
# escape=`
# Installer image
FROM microsoft/windowsservercore:1709 AS installer-env
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
# Retrieve .NET Core Runtime
ENV DOTNET_VERSION 2.0.6
ENV DOTNET_DOWNLOAD_URL https://dotnetcli.blob.core.windows.net/dotnet/Runtime/$DOTNET_VERSION/dotnet-runtime-$DOTNET_VERSION-win-x64.zip
@yizhang82
yizhang82 / coroutine-simple.cpp
Created October 28, 2017 07:21
Simple C++ coroutine example
#include <future>
#include <iostream>
using namespace std;
future<int> async_add(int a, int b)
{
auto fut = std::async([=]() {
int c = a + b;
return c;
'use strict'
var sqlite = require('sqlite3').verbose();
var db = new sqlite.Database('test_db');
db.getAsync = function (sql) {
var that = this;
return new Promise(function (resolve, reject) {
that.get(sql, function (err, row) {
if (err)
'use strict'
var sqlite = require('sqlite3').verbose();
var db = new sqlite.Database('test_db');
db.getAsync = function (sql) {
var that = this;
return new Promise(function (resolve, reject) {
that.get(sql, function (err, row) {
if (err)
'use strict'
var sqlite = require('sqlite3').verbose();
var db = new sqlite.Database('test_db');
function vote(voter, callback) {
var val;
var getStmt = `SELECT Name, Count FROM Voters WHERE Name="${voter}"`;
console.log(getStmt);
db.get(getStmt, function(err, row) {
@yizhang82
yizhang82 / rw_spin_lock.h
Created October 7, 2017 20:41
portable lock-free reader/writer lock for C++
class rw_spin_lock
{
public:
rw_spin_lock()
{
_readers = 0;
}
public:
void acquire_reader()
@yizhang82
yizhang82 / idispatch.cs
Last active November 15, 2023 22:09
Example on creating your own IDispatch implementation
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
@yizhang82
yizhang82 / valuetype.cs
Created March 19, 2017 07:25
Generic constraint on boxing
using System;
interface IAdd
{
void Add(int val);
}
struct Foo : IAdd
{
public int value;
@yizhang82
yizhang82 / host.cpp
Created January 28, 2017 07:43
Simple coreclr host
#include <iostream>
#include <limits.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <string.h>
#include <set>
#include <dirent.h>
#include <sys/stat.h>
#include "coreclrhost.h"