Skip to content

Instantly share code, notes, and snippets.

View Blokyk's full-sized avatar
👨‍🎓
Living and studying

Blokyk

👨‍🎓
Living and studying
  • 02:29 (UTC +02:00)
View GitHub Profile
@Blokyk
Blokyk / program.cs
Last active November 26, 2018 18:09
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
int initialPrice = Int32.Parse(Console.ReadLine());
int numberOfPrices = Int32.Parse(Console.ReadLine());
int[] prices = new int[numberOfPrices];

Lotus Syntax Module

11th of May, 2019

Last updated : 11th of May, 2019

Editors :

  • Blokyk
@Blokyk
Blokyk / primes.json
Created March 23, 2021 23:00
Comma-separated array of the first 10,000 primes, according to https://primes.utm.edu/lists/small/10000.txt
[
2,
3,
5,
7,
11,
13,
17,
19,
23,
@Blokyk
Blokyk / colors.cs
Last active June 15, 2021 14:25
X11 graphviz color palette enum
public enum Colors {
AliceBlue,
AntiqueWhite, AntiqueWhite1, AntiqueWhite2, AntiqueWhite3, AntiqueWhite4,
Aqua,
AquaMarine, AquaMarine1, AquaMarine2, AquaMarin3, AquaMarine4,
Azure, Azure1, Azure2, Azure3, Azure4,
@Blokyk
Blokyk / ValidOn.Verbose.cs
Last active June 15, 2021 15:21
All possible combinations of validity for graphviz attributes
[System.Flags]
public enum ValidOn {
Edge = 0,
EdgeNode = Edge & Node,
EdgeNodeGraph = EdgeNode & Graph,
EdgeNodeGraphSubgraph = EdgeNodeGraph & Subgraph,
EdgeNodeGraphSubgraphCluster = Edge & Node & Graph & Subgraph & Cluster,
EdgeNodeGraphCluster = EdgeNodeGraph & Cluster,
EdgeNodeSubgraph = EdgeNode & Subgraph,
EdgeNodeSubgraphCluster = EdgeNodeSubgraph & Cluster,
@Blokyk
Blokyk / funcs.glsl
Last active February 23, 2022 16:39
Cool fluid flow functions -- from anvaka.github.io/fieldplay
// Pay attention to the scaling !
// Some results might look boring or glitchy from afar (or close), but don't fret !
// p.x and p.y are current coordinates
// v.x and v.y is a velocity at point p
// https://bit.ly/3bmvQ58 -- zoomed in
vec2 get_velocity(vec2 p) {
vec2 v = vec2(0., 0.);
@Blokyk
Blokyk / display_clock.sh
Last active April 21, 2022 14:41
display_clock
#!/bin/bash
function center_txt() {
txt=$1
line_nb=$(wc -l <<< $txt)
available_lines=$(($(($LINES - $line_nb)) / 2))
#echo $available_lines
#echo "$txt"
perl -E "say \"\n\" x $available_lines"
#echo $top | wc -l
@Blokyk
Blokyk / better_merge_sort.c
Last active November 20, 2022 02:55
An implementation of MergeSort using two alternating buffers to avoid memcpy's (in pure C)
/*
* MIT License
*
* Copyright (c) 2022 blokyk
*
* 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
@Blokyk
Blokyk / SpanExtensions.cs
Created September 27, 2023 19:32
Reverse 4-bytes endianness of Span of bytes (not vectorized)
using System;
using System.Collections.Generic;
static class SpanExtensions
{
// just a quick and dirty version, could be a lot faster
// by just using Vector<byte>.Shuffle if available
public static void Reverse4ByteEndianness(Span<byte> bytes) {
byte b0, b1, b2, b3;
for (int i = 3; i < bytes.Length; i += 4) {
@Blokyk
Blokyk / EnumInfo.cs
Created October 20, 2023 22:39
Access info about a generic TEnum type in C#
using System.Runtime.CompilerServices;
/// <summary>
/// Computes various properties of <typeparamref name="TEnum"/>
/// </summary>
/// <remarks>WARNING: This assumes that <typeparamref name="TEnum"/>'s underlying type is an <see langword="int"/></remarks>
public static class EnumInfo<TEnum> where TEnum : struct, Enum
{
private static readonly Lazy<HashSet<TEnum>> _valuesSet = new(static () => new HashSet<TEnum>(EnumValues!));