Skip to content

Instantly share code, notes, and snippets.

View minhhungit's full-sized avatar
😘
Hello world

Jin minhhungit

😘
Hello world
View GitHub Profile
@minhhungit
minhhungit / wakeupapp-homeassistant.cs
Created February 25, 2019 11:33 — forked from rille111/wakeupapp-homeassistant.cs
Example for a C# .NET Home-Assistant consuming app
using System.Threading.Tasks;
using NLog;
using Rille.Hass.ApiProxy;
using Rille.Hass.AppStarter;
using Rille.Hass.Models.StateChangeEventGraph;
namespace HassLab.Console.HassApps
{
public class WakeUpApp : IHassApp
{
@minhhungit
minhhungit / mongodb_c#_cheatsheet.md
Created July 18, 2019 12:34 — forked from a3dho3yn/mongodb_c#_cheatsheet.md
MongoDB C# Driver Cheat Sheet

MongoDB C# Driver Cheat Sheet

(C) 2015 by Derek Hunziker, (C) 2017 by AppsOn

As of releasing MongoDB 3.4 and C# Driver v2.4, original cheatsheet by Derek is outdated. In addition, it has some deficiencies like connecting to MongoDB, creating indexes, etc. This updated version works fine with C# Driver v2.4.7 and MongoDB v3.4.

Setup

Define Document Models

Note: Defined models and collections will be used in entire cheatsheet.

@minhhungit
minhhungit / 101-rx-samples.md
Created December 28, 2019 13:31 — forked from omnibs/101-rx-samples.md
101 Rx Samples in C#

101 Rx Samples in C#

This was taken from http://rxwiki.wikidot.com/101samples, because I wanted to be able to read it more comfortable with syntax highlighting.

Here's the unedited original, translated to Github Markdown glory:

101 Rx Samples - a work in progress

static ushort GetShardId(string key)
{
using var md5 = MD5.Create();
{
var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(key));
var integer = BigInteger.Abs(new BigInteger(hash));
return (ushort)(integer % ushort.MaxValue);
}
}
@minhhungit
minhhungit / Shrink_Database_File_in_Specified_Increments.sql
Created August 15, 2021 06:19 — forked from EitanBlumin/Shrink_Database_File_in_Specified_Increments.sql
Shrink a database file in specified increments down to a specific size or percentage of used space
/*
----------------------------------------------------------------------------
Shrink a Database File in Specified Increments
----------------------------------------------------------------------------
Author: Eitan Blumin (t: @EitanBlumin | b: eitanblumin.com)
Creation Date: 2020-01-05
Last Update: 2020-08-23
----------------------------------------------------------------------------
Description:
This script uses small intervals to shrink a file (in the current database)
@minhhungit
minhhungit / Find SHRINK sessions with lock info.sql
Created August 15, 2021 06:20 — forked from EitanBlumin/Find SHRINK sessions with lock info.sql
SQL queries to troubleshoot a long-running DBCC SHRINK operation
/*
Author: Eitan Blumin | https://www.eitanblumin.com
Create Date: 2020-03-18
Last Update: 2020-06-22
Description:
This script will detect currently running sessions in your database which are running DBCC SHRINK commands.
It will also output the name of any tables and indexes the session is currently locking.
Use this query to find out what causes a SHRINK to run for too long.
You may need to run it multiple times to "catch" the relevant info.
@minhhungit
minhhungit / BitSet.cs
Created September 1, 2021 05:25 — forked from NightOwl888/BitSet.cs
C# port of the java.util.BitSet class
/* BitSet.cs -- A vector of bits.
Copyright (C) 1998, 1999, 2000, 2001, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
@minhhungit
minhhungit / RedisJobQueue.cs
Created December 8, 2022 14:44 — forked from tenowg/RedisJobQueue.cs
A Message/Job Queue based on StackExchange.Redis and Redis Server
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using StackExchange.Redis;
namespace CitySurvival.Redis
{
@minhhungit
minhhungit / CloudflareHttpHandler.cs
Created January 19, 2023 00:44 — forked from xHeaven/CloudflareHttpHandler.cs
Cloudflare http handler in C# allows scraping cloudflare protected websites
using System;
using System.Net.Http;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Threading;
using System.Collections.Generic;
using System.Linq;
using Microsoft.ClearScript.V8;
@minhhungit
minhhungit / GoDaddySSLHAProxy.md
Created January 28, 2023 10:57 — forked from sethwebster/GoDaddySSLHAProxy.md
Creating a PEM for HaProxy from GoDaddy SSL Certificate

GoDaddy SSL Certificates PEM Creation for HaProxy (Ubuntu 14.04)

1 Acquire your SSL Certificate

Generate your CSR This generates a unique private key, skip this if you already have one.

sudo openssl genrsa -out  etc/ssl/yourdomain.com/yourdomain.com.key 1024

Next generate your CSR (Certificate Signing Request), required by GoDaddy: