Skip to content

Instantly share code, notes, and snippets.

View chinhvo's full-sized avatar

Chinh Vo Wili chinhvo

View GitHub Profile
/**
* Methods required by a custom player for `react-player`
*/
export interface Player {
load(url?: string): void;
seekTo(amount: number, type?: 'seconds' | 'fraction'): void;
getCurrentTime(): number;
getDuration(): number;
getSecondsLoaded(): number | null;
stop?(): void;
import React, { Component } from "react";
import ReactPlayer, { ReactPlayerProps } from "react-player";
import { getSDK } from "react-player/lib/utils";
import {
Player,
IkWidget,
KalturaNotificationName,
KalturaPlayerElement,
KalturaPlayerEvents,
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 / bootstrap-tab-panel-example.markdown
Created March 10, 2022 03:34
Bootstrap tab panel example
@shubhamnikam
shubhamnikam / GithubController.cs
Last active August 21, 2023 02:43
Named Client implementation of IHttpClientFactory
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
namespace TestAPIGithub.Controllers
{
@shubhamnikam
shubhamnikam / Startup.cs
Created February 20, 2021 17:28
Setup HttpClient configuration in Startup.ConfigureService
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
//configure httpclient service
services.AddHttpClient("GithubAPI", client=>
{
//customize as per your need
client.BaseAddress = new Uri("http://api.github.com/");
client.DefaultRequestHeaders.Add("Accept", "application/vnd.github.v3+json");
const fs = require("fs");
const path = require("path");
function fixFile(filepath) {
const contents = fs.readFileSync(filepath, "utf-8");
const matcher = /([0-9]+(?:\.[0-9]+)?)rem/igm;
const result = contents.replaceAll(matcher, (substr, size) => {
const rem = Number(size);
@redatawfik
redatawfik / server.cpp
Created June 12, 2020 03:52
Server implementation of client-server chat using Winsock
#include <winsock2.h>
#include <iostream>
struct CLIENT_INFO {
SOCKET hClientSocket;
struct sockaddr_in clientAddr;
};
char szServerIPAddr[] = "192.168.1.4"; // Put here the IP address of the server
int nServerPort = 5050; // The server port that will be used by