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:
/* | |
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. |
/* | |
---------------------------------------------------------------------------- | |
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) |
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); | |
} | |
} |
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:
(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.
Note: Defined models and collections will be used in entire cheatsheet.
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 | |
{ |