Skip to content

Instantly share code, notes, and snippets.

View ridercz's full-sized avatar
🇨🇿

Michal Altair Valášek ridercz

🇨🇿
View GitHub Profile
@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);
@ridercz
ridercz / BridleTag.scad
Created March 8, 2022 01:36
Jmenovky na ohlávky v OpenSCADu
/* [Preview] */
base_color = "#333";
text_color = "#ddd";
/* [Text] */
// Displayed text
text = "ALTAIR";
// Displayed text font
text_font = "Arial Rounded MT Bold";
// Nominal font size
@ridercz
ridercz / privesky.scad
Created October 2, 2021 12:10
Generování přívěšků s čísly
/* [Tag options] */
diameter = 30;
thickness = 2;
extrusion = 1;
rim_width = 1.67;
hole_diameter = 4;
/* [Plater options] */
tag_start_number = 1;
tag_rows = 6;
@ridercz
ridercz / Altair-General.snippet
Created September 30, 2021 13:38
Visual Studio Code Snippets
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Insert input model subclass</Title>
<Author>Michal A. Valasek</Author>
<Shortcut>imodel</Shortcut>
</Header>
<Snippet>
<Code Language="csharp" Delimiter="$"><![CDATA[[BindProperty]