Skip to content

Instantly share code, notes, and snippets.

@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

Husky

Husky makes it straightforward to implement git hooks. Work with a team and want to enforce coding standards across the team? No problem! Husky lets you require everyone to automatically lint and tests their code before committing or pushing to the repository.

https://github.com/typicode/husky

dotenv

Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

@SMoni
SMoni / README.md
Created February 17, 2020 06:27 — forked from addyosmani/README.md
108 byte CSS Layout Debugger

CSS Layout Debugger

A tweet-sized debugger for visualizing your CSS layouts. Outlines every DOM element on your page a random (valid) CSS hex color.

One-line version to paste in your DevTools

Use $$ if your browser aliases it:

~ 108 byte version