Skip to content

Instantly share code, notes, and snippets.

View hancheester's full-sized avatar
👨‍💻
Coding

Han Chee Tan hancheester

👨‍💻
Coding
View GitHub Profile
@hancheester
hancheester / Program.cs
Created October 14, 2023 12:27
To hash password
using System.Security.Cryptography;
using System.Text;
namespace PasswordHasher
{
internal class Program
{
static void Main(string[] args)
{
const int keySize = 64;
/*
To parse value from a dynamic object.
*/
public T Parse<T>(dynamic value, string name)
{
if (CheckProperty(value, name))
{
var parts = name.Split(".");
-- Create table variable
declare @Temp as table
(
ID int not null primary key,
Data xml not null
)
-- Populate date into table variable
insert into @Temp (ID, Data)
select 1, '<Root xmlns:ns1="http://www.ns1.com/2010/1">
@hancheester
hancheester / find-all-objects-in-mssql-schema.sql
Last active November 8, 2019 22:57
To find all objects in SQL Server schema.
-- To find all objects in SQL Server schema
select * from sys.objects
where schema_id = SCHEMA_ID('dbo');
@hancheester
hancheester / view-content-of-a-sp.sql
Last active November 7, 2019 20:29
To view content of a stored proc
-- To view content of a stored proc
-- Option 1
exec sp_helptext 'dbo.NameOfTheSp'
-- Option 2
select OBJECT_DEFINITION(OBJECT_ID('NameOfTheSp'))
@hancheester
hancheester / net-user-domain.cmd
Last active November 6, 2019 22:11
To show which AD groups this account belongs to
rem To show which AD groups this account belongs to
net user /domain "username"
@hancheester
hancheester / copy-con.cmd
Last active November 6, 2019 22:12
To create file through the command line
rem To create file through the command line.
rem Press Ctrl+Z to create file.
rem Press Ctrl-C to cancel.
copy con myfile.txt
@hancheester
hancheester / tasks.json
Created November 3, 2019 00:39
To include -O and -Wall in args.
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "gcc.exe build active file",
"command": "C:\\mingw-w64\\x86_64-8.1.0-posix-seh-rt_v6-rev0\\mingw64\\bin\\gcc.exe",
"args": [
@hancheester
hancheester / program.c
Last active November 3, 2019 00:37
Test variables in C.
#include<stdio.h>
int main()
{
int apples;
int oranges;
int bananas;
printf("apples=%d oranges=%d bananas=%d", apples, oranges, bananas);
public static class UrlHelperExtensions
{
public static string GenerateAbsoluteUrl(this UrlHelper helper, string path, bool forceHttps = false)
{
const string HTTPS = "https";
var uri = helper.RequestContext.HttpContext.Request.Url;
var scheme = forceHttps ? HTTPS : uri.Scheme;
var host = uri.Host;
var port = (forceHttps || uri.Scheme == HTTPS) ? string.Empty : (uri.Port == 80 ? string.Empty : ":" + uri.Port);