Skip to content

Instantly share code, notes, and snippets.

View joeydebreuk's full-sized avatar

Joey van Breukelen joeydebreuk

View GitHub Profile
{
components: {
schemas: {
HALLink: {
type: 'object',
properties: {
api: { type: 'string', example: 'https://egeniq.com/page' },
web: { type: 'string', example: 'https://egeniq.com/page' }
},
required: [ 'api', 'web' ]
import {z} from "zod";
import {extendZodWithOpenApi, OpenAPIGenerator, OpenAPIRegistry} from "@asteasolutions/zod-to-openapi";
// We can now use `.openapi()` to specify OpenAPI metadata, eg z.string().openapi({ description: 'Some string' });
extendZodWithOpenApi(z);
const registry = new OpenAPIRegistry();
const HALLink = z.object({
api: z.string().openapi({ example: 'https://egeniq.com/page' }),
web: z.string().openapi({ example: 'https://egeniq.com/page' }),
@joeydebreuk
joeydebreuk / iframe-callback.html
Created June 28, 2022 12:32
iframe-callback.html
<!DOCTYPE html>
<html lang="fi">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
</body>
<script>
var params;
@joeydebreuk
joeydebreuk / strawberry-django-pagination.py
Created March 17, 2021 19:56
strawberry-django-pagination
"""
Usage like:
class SomeResolver(PaginationMixin, ModelResolver):
model = SomeModel
and
class SomeOtherResolver(PaginationMixin, ModelResolver):
model = SomeOtherModel
@joeydebreuk
joeydebreuk / getmessages.sh
Created February 14, 2020 14:35
Download export from Translationhut
#!/bin/bash
SECRET=YOURSECRET
WRITE_TO_DIR=src/messages
URL="https://translationhut.com/export/flat_json?languages=EN-US,NL-NL&include_empty=false"
# Download file to messages.zip
curl "$URL" -H "Authorization: Api-Key $SECRET" --output messages.zip
# unzip messages.zip to relative path folder, declared in "WRITE_TO_DIR"
@joeydebreuk
joeydebreuk / sendMissingTranslationKeys.js
Last active February 13, 2020 15:50
Send missing translations in your Vue project to TranslationHut
/*
This file can add all missing vue-i18n translations in
your Vue App to your TranslationHut.com project
Setup vue-i18n: https://kazupon.github.io/vue-i18n/started.html
Setup TranslationHut.com
1. Signup and create a project at TranslationHut.com
2. Go to "develop"
3. Create an API-key -> Paste the secret in this file
def permission_middleware(next, root, info, **args):
"""
Passes trough every field.
next: Call next to continue evaluation.
root: model instance which the field belongs to
args: dict of arguemnts passed to the field
Info params:
- field_name
- field_asts (info about field)
- return_type (of field)
@joeydebreuk
joeydebreuk / pickEntryByString.js
Created July 1, 2019 11:17
Get item from list based on any String
// Get item from list based on any String
// Example:
// var arr = [0, 1, 2, 3, 4, 5, 6];
// pickValueByString(arr, "Text"); // >> 1
// pickValueByString(arr, "text"); // >> 5
// pickValueByString(arr, "other text"); // >> 2
// pickValueByString(arr, "Text"); // >> 1
function byteValue(str) {
var totalBytes = 0;