Skip to content

Instantly share code, notes, and snippets.

View Mulugruntz's full-sized avatar
🇳🇱
In Amsterdam

Samuel GIFFARD Mulugruntz

🇳🇱
In Amsterdam
View GitHub Profile
@Mulugruntz
Mulugruntz / example.txt
Created October 23, 2023 08:27
Example of Callback Protocol
$ python3.11 -m mypy main.py
main.py:19: error: Argument 2 to "add_something" has incompatible type "Callable[[str], int]"; expected "SomeCallback" [arg-type]
Found 1 error in 1 file (checked 1 source file)
@Mulugruntz
Mulugruntz / russian_verbs.md
Last active February 20, 2023 14:28
Russian verbs

Russian Verbs

Russian verbs are divided into three categories: Group 1, Group 2, and Irregular Verbs.

  • Group 1 verbs have their infinitive end in -ать or -ять;
  • Group 2 verbs have their infinitive end in -ить (sometimes -еть);
  • Irregular verbs are verbs that do not follow the rules of Group 1 or Group 2.

Group 1

@Mulugruntz
Mulugruntz / russian_declensions.md
Created February 14, 2023 08:50
Noun declensions in Russian

Russian declensions

Spelling rules

  1. к, г, х are not followed by ы, but by и.
  2. ш, ж, ч, щ are not followed by ы, but by и.
  3. ш, ж, ч, щ and ц in unstressed endings are not followed by о, but by е.
  4. ш, ж, ч, щ and ц are not followed by я, but by а, and not by ю, but by у.

The noun

@Mulugruntz
Mulugruntz / about.md
Last active July 1, 2021 15:42
Woocommerce Bookings: New feature: full month is bookable

Woocommerce Bookings: New feature: full month is bookable.

Goal

This adds a new feature to Woocommerce Bookings 1.15.41. In a product availability, there's a new checkbox: Title: Full month is bookable? Description: Enabling this option will make bookings available until the end of the month. So if the end date would be June 7 or June 28, it would become June 30 in both cases.

@Mulugruntz
Mulugruntz / .env
Created April 9, 2021 09:22
EdgeDB backup/restore scripts (working with docker-compose)
###### .env ######
EDGEDB_USER="my_user"
EDGEDB_PASSWORD="my_password"
@Mulugruntz
Mulugruntz / edge_nested_tx.py
Last active April 2, 2021 01:36
EdgeDB 1-beta1 skip nested transactions
"""
A decorator to avoid WET code.
I happened to have to use the same function, sometimes
within a transaction, sometimes not.
However, I wanted my function to be executed in a
transaction (atomicity needed).
I didn't want to have to write twice the same function,
depending on whether it was inside a transaction or not.
@Mulugruntz
Mulugruntz / weird-numpy-ndarray.py
Created February 28, 2020 08:24
ndarray gets filled with or without the buffer being specified. It seems to read some memory it shouldn't have access to?
import numpy
val = numpy.ascontiguousarray(
[
[
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]],
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]],
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]],
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]],
[[4, 8, 15], [16, 23, 42], [4, 8, 15], [16, 23, 42], [4, 8, 15]],
@Mulugruntz
Mulugruntz / edgedb_insert_if_not_exists.py
Last active February 26, 2020 10:38
For EdgeDB.The asynchronous function `insert_if_not_exists` does exactly as it says.
import asyncio
from dataclasses import dataclass
from typing import Any, List
import edgedb
from edgedb import AsyncIOConnection
@dataclass
class EdgeObjectProperty:
@Mulugruntz
Mulugruntz / dayOfTheWeek.groovy
Created June 19, 2018 09:23
Get the day of the week in Jenkins pipeline / Groovy
import java.text.SimpleDateFormat
import java.util.Date
def day = new SimpleDateFormat('EEEE').format(new Date())
println day // Tuesday (for example)
@Mulugruntz
Mulugruntz / pycharm.sh
Created November 19, 2017 16:50
PyCharm installation script
# Copyright (c) 2015 Jim Rybarski
# 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
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in