- Windows 11 Download Link
- Install Windows 11 on non-TPM CPUs [reference]
- Open registry editor
- Registry Key: HKEY_LOCAL_MACHINE\SYSTEM\Setup\MoSetup
- Name: AllowUpgradesWithUnsupportedTPMOrCPU
- Type: REG_DWORD
- Value: 1
“No problem can be solved from the same level of consciousness that created it.” Albert Einstein (1879-1955)
Wednesday, 24 November 2021
Windows 11 - Download and Install
Monday, 16 August 2021
Linux CentOS - Enable Network Adaptor and Assign Static IP Address
To deploy OVA or OVF file,
- Login to VCenter with the Administrator account
- Make sure to use FQDN in URL instead of IP Address
- In case image file cannot be recognized by the version of VCenter, run command shell as admin and issue the following command
- tar -xvf yourfilename.ova
Monday, 9 August 2021
NodeJS and SQL
// npm install express --save
// npm install mssql --save
// npm install -g nodemon
// nodemon app.js
var express = require('express');
var sql = require('mssql');
var app = express();
app.use(express.json()); // parse json body
var _PROTOCOL = 'HTTP';
var _SERVER = 'localhost';
var _PORT = 4444;
var _DEFAULTPORT = 9000;
// config for database
var config = {
user: '****',
password: '****',
server: 'localhost',
database: 'mosis_portal',
stream: false,
options: {
trustedConnection: true,
encrypt: true,
enableArithAbort: true,
trustServerCertificate: true, // incase recieve error: self signed certificate
}
};
app.get('/posts', function(req, res) {
sql.connect(config, function(err) {
if (err) console.log(err);
var request = new sql.Request();
request.query('select * from posts').then(recordset => {
console.log(recordset.recordsets);
res.status(200).send(recordset.recordsets);
});
});
});
app.get('/post/:id', function (req, res) {
var id = req.params.id;
sql.connect(config, function(err, result, fields) {
if (err) console.log(err);
var request = new sql.Request();
request.query(`select * from posts where id= ${id}`).then(recordset => {
res.status(200).send(recordset.recordsets.pop().pop());
});
});
});
app.get('/title/:id', function (req, res) {
var id = req.params.id;
sql.connect(config, function(err, result, fields) {
if (err) console.log(err);
var request = new sql.Request();
request.query(`select top 1 * from posts where id= ${id}`).then(recordset => {
var info = recordset.recordsets.pop().pop();
var title = info.post_title;
var id = info.id;
console.log(info.id)
res.status(200).send(`<h1 onclick="location.href='http://localhost:4444/post/${id}'">${title}</h1>`);
});
});
});
app.listen(_PORT || _DEFAULTPORT, function() {
console.log(`\n\nServer running: ${_PROTOCOL}://${_SERVER}:${_PORT || _DEFAULTPORT}`);
});
Tuesday, 4 May 2021
SQL Recursion
-- Recursive SQL
WITH t(n) AS (
SELECT 1
UNION ALL
SELECT n+1 FROM t WHERE n< 5
)
SELECT n
FROM t
-- Data Generation with Recursive SQL
WITH
t1(v1, v2) AS (SELECT 1, 2),
t2(w1, w2) AS (
SELECT v1 * 2, v2 * 2
FROM t1
)
SELECT *
FROM t1, t2
Thursday, 4 March 2021
Detect SQL Database Changes using C# Table Dependency and SQL Broker
using System;
using TableDependency.SqlClient;
using TableDependency.SqlClient.Base;
using TableDependency.SqlClient.Base.Enums;
using TableDependency.SqlClient.Base.EventArgs;
namespace SQLCDC
{
class
Program
{
static
void Main(string[] args)
{
string
connectionString = "Server=localhost;Database=Test;Integrated
Security=True;";
var
mapper = new ModelToTableMapper<People>();
mapper.AddMapping(c
=> c.name, "Name");
mapper.AddMapping(c
=> c.age, "Age");
using
(var dep = new SqlTableDependency<People>(connectionString,
"People", mapper: mapper))
{
dep.OnChanged
+= Changed;
dep.Start();
Console.ReadKey();
dep.Stop();
}
}
public
static void Changed(object sender, RecordChangedEventArgs<People> e)
{
var
changedEntity = e.Entity;
if
(e.ChangeType != ChangeType.None)
{
switch
(e.ChangeType)
{
case
ChangeType.Delete:
break;
case
ChangeType.Update:
break;
case
ChangeType.Insert:
break;
case
ChangeType.None:
Console.WriteLine("None");
break;
}
}
Console.WriteLine("DML
OPR: " + e.ChangeType);
Console.WriteLine(" Name: " + changedEntity.name);
Console.WriteLine(" Age: " + changedEntity.age);
Console.WriteLine();
}
}
public
class People
{
public
string name { get; set; }
public
string age { get; set; }
}
}
/*
use
master
select
is_broker_enabled from sys.databases where name= 'Test'
use
test
go
create
table people (
id
int identity (1,1) not null,
name
varchar(50) not null,
age
nchar(10),
primary
key (id)
)
select
* from people
insert
into people (name, age) values ('A', 45)
insert
into people (name, age) values ('B', 50)
insert
into people (name, age) values ('C', 23)
select
* from people
update
people set name='A1' where name='A'
--
truncate table people
*/
Read more...
SQL: Generate a range of numbers
SELECT ones.n + 10*tens.n + 100*hundreds.n + 1000*thousands.n FROM (VALUES(0),(1),(2),(3),(4),(5),(6),(7),(8),(9)) ones(n), (VALU...
-
//convert BASE64 string to Byte{} array function base64ToArrayBuffer(base64) { var binaryString = window.atob(base64); var binar...
-
static void Main(string[] args) { // create a dummy list List<string> data = GetTheListOfData(); // split the lis...
-
var htmlToPdf = new NReco.PdfGenerator.HtmlToPdfConverter(); htmlToPdf.PageFooterHtml = @"<div style='text-align:right; font-s...