Skip to content

Instantly share code, notes, and snippets.

View ridercz's full-sized avatar
🇨🇿

Michal Altair Valášek ridercz

🇨🇿
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ridercz
ridercz / Encoding.ipynb
Created July 15, 2025 19:38
Base16, Base32 and Base64 in .NET
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ridercz
ridercz / Hash.ipynb
Last active April 8, 2025 14:02
Hashovací algoritmy nejenom v .NET
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ridercz
ridercz / SparseColumns.sql
Created March 4, 2025 23:01
Find candidates for sparse columns in MS SQL
SET NOCOUNT ON
CREATE TABLE #SparseTypes (
[DataType] nvarchar(20),
[Percentage] int
)
-- Values from https://learn.microsoft.com/en-us/sql/relational-databases/tables/use-sparse-columns
INSERT INTO #SparseTypes VALUES('bit', 98)
INSERT INTO #SparseTypes VALUES('tinyint', 86)
INSERT INTO #SparseTypes VALUES('smallint', 76)
@ridercz
ridercz / hierarchyid.sql
Created February 10, 2025 15:06
SQL Server HierarchyId demo
-------------------------------------------------------------------------------
-- Using linked IDs
-------------------------------------------------------------------------------
-- Create table
CREATE TABLE Categories (
[Id] int IDENTITY NOT NULL,
[ParentId] int NULL,
[Name] nvarchar(100) NOT NULL,
@ridercz
ridercz / ProcessIO.cs
Created January 20, 2025 22:29
Running external process with stdin/out/err redirection
// Video: https://youtu.be/cdTu27j6dn8
using System.Diagnostics;
using System.Text;
// Verify there are exactly 2 arguments and get source and destination folders
if (args.Length != 2) {
Console.WriteLine("Usage: mirror <source folder> <destination folder>");
return;
}
@ridercz
ridercz / SerialPlotter.ino
Created January 17, 2025 00:11
M5Stack CoreS3 + ENV unit demo for Arduino serial plotter
#include "M5CoreS3.h"
#include "M5UnitENV.h"
SHT3X sht3x;
QMP6988 qmp;
void setup()
{
auto cfg = M5.config();
CoreS3.begin(cfg);
@ridercz
ridercz / RoundedTimeProvider.cs
Last active October 9, 2024 22:24
TimeProvider for .NET supporting rounding time to last second or minute and time zone conversions
public class RoundedTimeProvider : TimeProvider {
// Private constructor to prevent direct instantiation
private RoundedTimeProvider() { }
// Factory methods for different precisions
public static RoundedTimeProvider NativePrecision(string? localTimeZoneName = null) => new() {
LocalTimeZoneInternal = localTimeZoneName == null ? TimeZoneInfo.Local : TimeZoneInfo.FindSystemTimeZoneById(localTimeZoneName),
RoundingFunction = x => x,
@ridercz
ridercz / Program.cs
Last active May 9, 2022 21:09
Using Hangfire in ASP.NET Core 6.0
/* This is sample code for the following video: https://youtu.be/36p2-gr_iYk
* The following NuGet packages are needed:
* Hangfire
* Hangfire.AspNetCore
* Hangfire.SqlServer
*/
using Hangfire;
var builder = WebApplication.CreateBuilder(args);