Skip to content

Instantly share code, notes, and snippets.

View Guiorgy's full-sized avatar

Guiorgy Guiorgy

  • Ecopre
  • Georgia
View GitHub Profile
@Guiorgy
Guiorgy / FenwickTree.cpp
Created December 16, 2018 21:20
FenwickTree structure for c++
struct FenvickTree {
struct Node {
int Value;
int Sum;
int Parent;
int Next;
};
vector<Node> Tree;
@Guiorgy
Guiorgy / Xamarin.Android Manifest merging workaround.md
Last active June 12, 2019 09:32
Currently (11/1/19) Xamarin does not support merging manifest, or having different manifests for different build configurations. This is a workaround originally found by AlexanderMelchers at https://forums.xamarin.com/discussion/97461/android-manifest-file-merge-rules
  1. Download AXMLPrinter2.jar from https://code.google.com/archive/p/android4me/downloads
  2. Build your solution and create an archive (.apk) by selecting Build->Archive...
  3. After archiving is done, open folder and find the archived *.apk, open the archive (for example using 7Zip) and extract/unzip AndroidManifest.xml
  4. Open any text editor and type: start cmd.exe /c "java -jar AXMLPrinter2.jar AndroidManifest.xml > AndroidManifest.plaintext.xml" and save it as a *.bat file in the same directory
  5. Run the *.bat file and check the resulting AndroidManifest.plaintext.xml file. This is the file we will be editing using a shell script
  6. Create the shell script you need. It should target obj$configuration\android\AndroidManifest.xml for example: (Get-Content 'obj\Release*\android\AndroidManifest.xml').replace('', '') | Set-Content 'obj\Release*\android\AndroidManifest.xml' the RemoveAndroidPermission.ps1 script above finds RE
@Guiorgy
Guiorgy / PrimitiveContainerConverter.java
Created June 19, 2019 10:57
A simple List to primitive array, and primitive array to List converter
@SuppressWarnings({"WeakerAccess", "unused"})
public abstract class PrimitiveContainerConverter {
public interface ListByteRef extends Supplier<List<? extends Byte>> {}
/**
* Convert Lists of {@link Byte} to array of primitive type byte
*
* usage: array = toPrimitiveArray(() -> list);
*/
public static byte[] toPrimitiveArray(final ListByteRef byteListRef) {
List<? extends Byte> byteList = byteListRef.get();
@Guiorgy
Guiorgy / ReverseSeekBar.kt
Last active February 20, 2020 20:01
An Android SeekBar, that's flipped horizontally
class ReverseSeekBar : SeekBar {
constructor(context: Context) : super(context) {
init()
}
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs) {
init()
}
constructor(context: Context, attrs: AttributeSet?, defStyle: Int) : super(context, attrs, defStyle) {
init()
@Guiorgy
Guiorgy / ProgressNotificationManager.kt
Last active March 23, 2020 22:39
A NotificationManagerCompat wrapper made to simplify handling of progress notifications
import android.annotation.SuppressLint
import android.annotation.TargetApi
import android.app.Notification
import android.app.NotificationChannel
import android.content.Context
import android.os.Build
import androidx.annotation.IntDef
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.app.NotificationManagerCompat
@Guiorgy
Guiorgy / ASCII_TO_GEORGIAN.sql
Last active January 31, 2024 13:27
Create an SQL function that converts ASCII characters to Georgian. (Useful for storing Georgian strings in the database using the ASCII encoding to save space and improve compatibility)
CREATE FUNCTION [dbo].[ASCII_TO_GEORGIAN] (@ascii nvarchar(max))
RETURNS NVARCHAR(MAX)
AS
BEGIN
DECLARE @ret NVARCHAR(max);
SET @ret =
REPLACE(
REPLACE(
REPLACE(
REPLACE(
// 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;
@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)