Skip to content

Instantly share code, notes, and snippets.

sudo pacman -Scc
sudo pacman -Syu
public Guid combineThose(Guid[] IDs_) {
const int length = 16;
return IDs_.Aggregate(Guid.Empty, (Accumulate, Current) => {
var result = new byte[length];
var asByteArrayAccumulate = Accumulate.ToByteArray();
var asByteArrayCurrent = Current.ToByteArray();
@SMoni
SMoni / createEnumaration.js
Last active December 31, 2022 10:04
Simple function to create an enumeration (sort of), in which the key and the value match.
'use strict';
const createEnumeration = (...keys) =>
keys.reduce(
(result, key) => Object.assign(result, { [key]: key }),
{}
);
const myEnum = createEnumeration(
'first',
@SMoni
SMoni / do_magic.py
Created December 26, 2022 13:49
What will this method do...
def do_magic(decimal_num:int):
if decimal_num < 2:
return decimal_num
result = 0
square_num = 2
while square_num < decimal_num:
square_num *= 2
@SMoni
SMoni / Copy-Dependencies.ps1
Last active June 30, 2022 18:49
Copy all npm-packages for production into the dist-folder
Clear-Host
Set-Location $PSScriptRoot
$main = {
npm list --prod |
Select-Object -Skip 1 | # First line is the project itself
Get-Dependency |
Sort-Object |
Get-Unique |
const myArray = Array.from({length: 10}, (e, i)=> i)
doWork(
doSomethingWith,
myArray,
logToConsole
)
//Die Funktion, die das Ganze abarbeitet
async function doWork(doSomething, anArray, aCallback) {
$sample = @(
[PSCustomObject]@{
From = [datetime]::Parse("01.01.2022 00:00:00")
To = [datetime]::Parse("10.01.2022 23:59:59")
}
[PSCustomObject]@{
From = [datetime]::Parse("05.01.2022 00:00:00")
To = [datetime]::Parse("15.01.2022 23:59:59")
}
[PSCustomObject]@{
@SMoni
SMoni / ConvertFromCsv.cs
Last active December 5, 2021 12:22
Converts Csv with header from a TextReader
public static class ReadFromCsv {
public static IEnumerable<IDictionary> asKeyValuePairs(this TextReader Reader_, string Delimiter_ = ";") {
var splitThis = Delimiter_.asSplitter();
var result = new List<Dictionary<string, object>>();
var columns = splitThis(Reader_.ReadLine());
@SMoni
SMoni / combineGuids.ps1
Created July 5, 2021 10:41
Combine two guids
function combineIds() {
param(
[Parameter()]
[Guid]$First,
[Parameter()]
[Guid]$Second
)
function getStartOfWeek() {
begin {
$base = [DayOfWeek]::Monday
}
process {
$difference = $_.DayOfWeek - $base
$offset = (7 + $difference) % 7 * -1