Skip to content

Instantly share code, notes, and snippets.

View chinhvo's full-sized avatar

Chinh Vo Wili chinhvo

View GitHub Profile
app.MapGet("/background", (
PeriodicHostedService service) =>
{
return new PeriodicHostedServiceState(service.IsEnabled);
});
class PeriodicHostedService : BackgroundService
{
private readonly TimeSpan _period = TimeSpan.FromSeconds(5);
private readonly ILogger<PeriodicHostedService> _logger;
private readonly IServiceScopeFactory _factory;
private int _executionCount = 0;
public bool IsEnabled { get; set; }
public PeriodicHostedService(
ILogger<PeriodicHostedService> logger,
private int _executionCount = 0;
public bool IsEnabled { get; set; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
using PeriodicTimer timer = new PeriodicTimer(_period);
while (
!stoppingToken.IsCancellationRequested &&
await timer.WaitForNextTickAsync(stoppingToken))
{
@chinhvo
chinhvo / CRUD_SP_Generation.sql
Created May 4, 2023 07:35 — forked from huobazi/CRUD_SP_Generation.sql
Generate CRUD stored procedures from tables in schema
-- #########################################################
-- Author: www.sqlbook.com
-- Copyright: (c) www.sqlbook.com. You are free to use and redistribute
-- this script as long as this comments section with the
-- author and copyright details are not altered.
-- Purpose: For a specified user defined table (or all user defined
-- tables) in the database this script generates 4 Stored
-- Procedure definitions with different Procedure name
-- suffixes:
-- 1) List all records in the table (suffix of _GetAll)
@chinhvo
chinhvo / autoSizr.js
Created September 26, 2022 14:01 — forked from iamkirkbater/autoSizr.js
Simple jQuery Plugin that auto resizes text to fill a specific sized div (great for responsive slideshows that utilize large banner text with variable lengths), derived from https://gist.github.com/iam4x/5015270
$.fn.autoSizr = function () {
var el, elements, _i, _len, _results;
elements = $(this);
if (elements.length < 0) {
return;
}
_results = [];
for (_i = 0, _len = elements.length; _i < _len; _i++) {
el = elements[_i];
_results.push((function(el) {
@chinhvo
chinhvo / countries.sql
Created August 16, 2022 08:59 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@chinhvo
chinhvo / bootstrap-tab-panel-example.markdown
Created March 10, 2022 03:34
Bootstrap tab panel example
@chinhvo
chinhvo / table.html
Created February 15, 2022 08:08 — forked from Sudheendra123/table.html
Table with Checkbox and checkall options
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Bootstrap Table Checkbox Select All and Cancel</title>
<link href="//cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h2>Bootstrap Table Checkbox Select All and Cancel</h2>
<table class="table table-striped">
@chinhvo
chinhvo / ConditionalValidationAttribute.cs
Created September 5, 2021 14:44 — forked from FWest98/ConditionalValidationAttribute.cs
.NET Core 3 Conditional Model Validation Attribute
using System;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
namespace Foo {
// Implementation makes use of the IPropertyValidationFilter interface that allows
// control over whether the attribute (and its children, if relevant) need to be
// validated.
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class ConditionalValidationAttribute : Attribute, IPropertyValidationFilter {
public string OtherProperty { get; set; }
@chinhvo
chinhvo / gist:eb000e31009b2d6f9de87788c0b02671
Created June 24, 2021 03:55 — forked from lukas-vlcek/gist:5143799
Adding a new analyzer into existing index in Elasticsearch (requires close/open the index). Tested with Elasticsearch 0.19.12.
// create an index with an analyzer "myindex"
curl -X PUT localhost:9200/myindex -d '
{
"settings" : {`
"index":{
"number_of_replicas":0,
"number_of_shards":1,
"analysis":{
"analyzer":{
"first":{