Skip to content

Instantly share code, notes, and snippets.

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

Han Chee Tan hancheester

👨‍💻
Coding
View GitHub Profile
-- To display all tables in a database.
select TABLE_NAME
from YourDatabase.INFORMATION_SCHEMA.TABLES
where TABLE_TYPE = 'BASE TABLE'
-- To get a list of databases.
select name from sys.databases;
/*
Function to show component border together with component name. It is useful for AngularJS component-based application design.
*/
(function () {
'use strict';
var app = angular.module('app');
app.run(function () {
/*
A function to verify Google reCAPTCHA (server side integration)
*/
protected bool VerifyRecaptcha()
{
var values = new Dictionary<string, string>
{
{ "secret", ConfigurationManager.AppSettings["recaptcha:SecretKey"] },
{ "response", HttpContext.Request["g-recaptcha-response"] },
{ "remoteip", HttpContext.Request.UserHostAddress },
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);
@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);
@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 / 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 / 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 / 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'))