Skip to content

Instantly share code, notes, and snippets.

View Guiorgy's full-sized avatar

Guiorgy Guiorgy

  • Ecopre
  • Georgia
View GitHub Profile
// prime calculation based on https://gist.github.com/rongjiecomputer/d52f34d27a21b8c9c9e82ca85b806640
// add increase limits or it wont compile for sieveSize = 1000000 -fconstexpr-loop-limit=2000000 -fconstexpr-ops-limit=335544320
// use debug build.
// release build will optimize most of the loop away.
#include <chrono>
#include <iostream>
#include <numeric>
#include <span>
#include <stdio.h>
// prime calculation based on https://gist.github.com/rongjiecomputer/d52f34d27a21b8c9c9e82ca85b806640
// add increase limits or it wont compile for sieveSize = 1000000 -fconstexpr-loop-limit=2000000 -fconstexpr-ops-limit=335544320
// use debug build.
// release build will optimize most of the loop away.
#include <chrono>
#include <iostream>
#include <numeric>
#include <span>
#include <stdio.h>
@Guiorgy
Guiorgy / Makefile
Created April 15, 2021 14:43
C++ library Makefile template
# Makefile based on https://gist.github.com/rioki/3957339 and https://stackoverflow.com/a/12099167
PACKAGE = my_package
VERSION = 1.0.0
CXX ?= g++ -std=c++0x
CXXFLAGS += -march=native -I include -D VERSION=\"$(VERSION)\" -D MY_PACKAGE_EXPORTS
LDFLAGS +=
ifeq ($(OS),Windows_NT)
@Guiorgy
Guiorgy / VigenereCipher.cs
Last active November 12, 2022 23:34
A simple implementation of the Vigenere Cipher in C#
// #define VERBOSE // define for debug logs
// By deafult the alphabet only includes Lowercase Latin letters and the space character
#define INCLUDE_UPPER // define to include Uppercase Latin letters
#define INCLUDE_NUMBERS // define to include numbers
#define INCLUDE_SYMBOLS // define to include other valid ASCII characters
// #define INCLUDE_GEORGIAN // define to include Georgian letters
#define IGNORE_INVALID_CHARACTERS // define to discard invalid characters without stopping the algorithm
using System;
@Sieboldianus
Sieboldianus / README.md
Last active March 1, 2026 21:04 — forked from centic9/README.md
Notepad++ syntax highlighting for Dockerfiles (Dark version)

Notepad++ syntax highlighting for Dockerfiles (Dark version)

Store userDefineLang_DockerfileDark.xml at %AppData%\Roaming\Notepad++\userDefineLangs\userDefineLang_DockerfileDark.xml and select Language > Dockerfile in Notepad++.

This color theme is specifically compatible with VS2015-Dark-Npp Theme.

Automatically apply style

@Guiorgy
Guiorgy / StringReplaceTokensBatchFast.cs
Last active November 15, 2022 16:01
Search occurrences of specified tokens (character sequences surrounded by specified prefix and postfix delimiters) in a string and replace them with other specified strings faster and with less memory usage
public static class StringExtensionMethods
{
/**
* Returns a new string in which all occurrences of specified tokens (character sequences surrounded
* by the specified prefix and postfix delimiters) in the current string are replaced with other specified strings.
*
* All tokens must start and end with the same prefix and postfix delimiters.
* `toReplace` strings in the batch should not have those delimiters explicitly included.
*/
public static string ReplaceBatch(this string origin, char prefix, char postfix, params (string toReplace, string replaceWith)[] batch)
@Guiorgy
Guiorgy / MutableString.cs
Last active November 24, 2022 14:53
An "evil" C# wrapper class that allows the mutation of the internal string object
/// <summary>
/// <strong>This class uses unsafe code and is only meant as a thought experiment. Do NOT use this in production!</strong>
/// <para/>
/// A wrapper to a string object that allows the mutation of the said string.
/// </summary>
public sealed class MutableString
{
/**
* We are assuming that if we allocate a char[] array and write it in a specific way that
* taking a reference to one of it's elements, we can "fool" .NET into thinking that that's
@Guiorgy
Guiorgy / git-aliases.sh
Last active April 14, 2026 17:03
Useful git aliases
#!/bin/bash
# Set the default branch name to main
git config --global init.defaultBranch main
# Alias for listing all defined aliases
git config --global alias.alias '! git config --get-regexp ^alias\. | sed -e s/^alias\.// -e s/\ /\ =\ /'
# Usage: git alias
# Alias to initialize a repository and print information that might be useful
@Guiorgy
Guiorgy / ReadOnlySpan.py
Last active January 21, 2025 15:04
A Python 3.11 implementation of a Read Only Span
# Copyright © 2023 Guiorgy
#
# This program 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 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.
@Guiorgy
Guiorgy / CheckBoxLabeled.xaml
Last active January 21, 2025 13:45
A custom MAUI view that combines a CheckBox with a Label and reacts to taps to both the CheckBox and Label
<?xml version="1.0" encoding="utf-8" ?>
<!--
Copyright 2023 Guiorgy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is