Skip to content

Instantly share code, notes, and snippets.

View chinhvo's full-sized avatar

Chinh Vo Wili chinhvo

View GitHub Profile
@chinhvo
chinhvo / gist:1e96341d9873501e8bd5afd336854983
Created December 7, 2017 08:19 — forked from voskobovich/gist:43f851859c23a8261514
The list of countries with currency (ISO code and symbol) format in SQL.
DROP TABLE currency;
-- Create table variable
CREATE TABLE currency (
country VARCHAR(100),
currency VARCHAR(100),
code VARCHAR(100),
symbol VARCHAR(100)
);
CREATE TABLE #Organization(Id INT, ParentID INT, Name nvarchar(20));
INSERT INTO #Organization VALUES(1,NULL,'A');
INSERT INTO #Organization VALUES(2,NULL,'B');
INSERT INTO #Organization VALUES(3,NULL,'C');
INSERT INTO #Organization VALUES(4,1,'A->D');
INSERT INTO #Organization VALUES(5,2,'B->E');
INSERT INTO #Organization VALUES(6,3,'C->F');
@chinhvo
chinhvo / runner.cs
Created May 8, 2018 07:37 — forked from hkulekci/runner.cs
c# run program on background with inline event handler.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Threading;
using System.Windows.Forms;
using System.ComponentModel;
namespace TestProject
@chinhvo
chinhvo / Installation.bat
Created May 9, 2018 08:05 — forked from aturgarg/Installation.bat
install, uninstall, start, stop a window service via command prompt
install window service
serviceName /i ( via cmd)
or
Installutil servicename (via Visual studio cmd prompt)
start window service via command prompt
net start servicename ( via cmd)
stop window service via command prompt
net stop servicename ( via cmd)
@chinhvo
chinhvo / AddAllClaimAction.cs
Created May 18, 2018 14:05 — forked from bjcull/AddAllClaimAction.cs
Adds all custom claims to the asp.net core identity
public class AddAllClaimAction : ClaimAction
{
public AddAllClaimAction() : base(null, null)
{
}
public override void Run(JObject userData, ClaimsIdentity identity, string issuer)
{
var claims = userData.Properties()
.Where(x => !x.Value.HasValues)
public static class AsExpandableExtension
{
public static IQueryable<T> AsExpandable<T>(this IQueryable<T> source)
{
if (source is ExpandableQuery<T>)
{
return (ExpandableQuery<T>)source;
}
@chinhvo
chinhvo / TimeService.cs
Created May 18, 2018 14:06 — forked from bjcull/TimeService.cs
The current time service I use to keep track of dates relative to a certain timezone.
public class TimeService : ITimeService
{
private readonly ILogger _logger;
private Instant? _frozenTime;
private Instant _realTimeAtTimeOfFreezing = Instant.MinValue;
private readonly IDateTimeZoneProvider _timeZoneProvider = DateTimeZoneProviders.Tzdb;
private readonly DateTimeZone _timeZone;
public TimeService(ILogger logger, string systemTimeZone, DateTime? setDate = null)
@chinhvo
chinhvo / ActiveRouteTagHelper.cs
Created May 18, 2018 14:06 — forked from bjcull/ActiveRouteTagHelper.cs
Adds an "active" class to the given element when the route parameters match. An Active Route Tag Helper.
[HtmlTargetElement(Attributes = "is-active-route")]
public class ActiveRouteTagHelper : TagHelper
{
private IDictionary<string, string> _routeValues;
/// <summary>The name of the action method.</summary>
/// <remarks>Must be <c>null</c> if <see cref="P:Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper.Route" /> is non-<c>null</c>.</remarks>
[HtmlAttributeName("asp-action")]
public string Action { get; set; }
@chinhvo
chinhvo / loading-button.js
Created May 18, 2018 14:06 — forked from bjcull/loading-button.js
An angular directive for the Ladda loading button. (Requires the jquery ladda plugin).
.directive('loadingButton', [
'$compile', function($compile) {
return {
restrict: 'A',
link: function(scope, element, attr) {
/* attr.style == "data-style" */
if (attr.loadingButtonAnimation && !attr.style) {
element.attr("data-style", attr.loadingButtonAnimation);
} else if (!attr.loadingButtonAnimation && !attr.style) {
element.attr("data-style", "slide-left");
@chinhvo
chinhvo / ChartDraw.html
Created May 18, 2018 14:07 — forked from bjcull/ChartDraw.html
A prototype graph with user drawn lines over the top
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.min.js"></script>