Skip to content

Instantly share code, notes, and snippets.

Yi Zhang yizhang82

Block or report user

Report or block yizhang82

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yizhang82
yizhang82 / aspnetcore-2.0-windowsservercore-1709
Last active Apr 13, 2018
Asp.NET core runtime environment on Windows Server Core 1709 on .NET Core 2.0.6 runtime
View aspnetcore-2.0-windowsservercore-1709
# 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 Apr 12, 2018
Dotnet 2.0.6 runtime image on Windows Server Core 1709
View dotnet-2.0.6-windowsservercore-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 Oct 28, 2017
Simple C++ coroutine example
View coroutine-simple.cpp
#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;
View sqlite-await.js
'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)
View sqlite-promise.js
'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)
View sqlite-callback.js
'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 Oct 7, 2017
portable lock-free reader/writer lock for C++
View rw_spin_lock.h
class rw_spin_lock
{
public:
rw_spin_lock()
{
_readers = 0;
}
public:
void acquire_reader()
@yizhang82
yizhang82 / idispatch.cs
Last active Jun 24, 2019
Example on creating your own IDispatch implementation
View idispatch.cs
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 Mar 19, 2017
Generic constraint on boxing
View valuetype.cs
using System;
interface IAdd
{
void Add(int val);
}
struct Foo : IAdd
{
public int value;
@yizhang82
yizhang82 / host.cpp
Created Jan 28, 2017
Simple coreclr host
View host.cpp
#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"
You can’t perform that action at this time.