Skip to content

Instantly share code, notes, and snippets.

View marcj's full-sized avatar
🖌️
Data

Marc J. Schmidt marcj

🖌️
Data
View GitHub Profile
@marcj
marcj / form.ts
Created March 20, 2024 21:55
Deepkit Angular 2
/*
* Deepkit Framework
* Copyright (C) 2021 Deepkit UG, Marc J. Schmidt
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the MIT License.
*
* You should have received a copy of the MIT License along with this program.
*/
@marcj
marcj / component.ts
Last active March 20, 2024 21:52
Deepkit Angular form
export class OrderFilter {
order: string = '';
customer: string = '';
article: string = '';
}
@Component({
template: `
@marcj
marcj / app.ts
Created September 24, 2023 16:55
Deepkit dot path to objects serializer
test('dot path to objects', () => {
//given values like { "myArray[0].prop1.prop2": "123" } we want to convert it to { myArray: [{ prop1: { prop2: "123" } }] }
interface MyObject {
myArray: { prop1: { prop2: string } }[];
}
function convertPathObjectToValues(object: { [name: string]: any }): any {
//object has keys like "myArray[0].prop1.prop2"
@marcj
marcj / lstm.py
Last active May 9, 2023 18:28
Mini calculator LSTM
"""
This script tests how good LSTMs are at solving mini calc tasks like 1+2, 3+4, 5*5.
The challenge is that the input is as string and can have arbitrary many whitespaces between the numbers and operator.
"1+2"
" 2 * 4"
" 3 + 3"
To have the problem simple enough, only 1 digit numbers are allowed. So 1+2, but not 11+2. And only 2 operators: + and *.
import { AbstractControl, FormArray, FormControl, FormControlOptions, FormControlState, FormGroup, ValidationErrors, ValidatorFn } from "@angular/forms";
import { ClassType, isFunction } from "@deepkit/core";
import {
deserialize,
getValidatorFunction,
hasDefaultValue,
isCustomTypeClass,
isOptional,
isType,
ReflectionClass,
@marcj
marcj / diff.patch
Last active July 8, 2022 21:21
NX watch bug
~
diff --git a/apps/frontend/src/app/app.tsx b/apps/frontend/src/app/app.tsx
index 0a2d3c2..7df6a6e 100644
--- a/apps/frontend/src/app/app.tsx
+++ b/apps/frontend/src/app/app.tsx
@@ -1,9 +1,11 @@
import React, { useEffect, useState } from 'react';
-import { Message } from '@foo23/api-interfaces';
+import { Message, User } from '@foo23/api-interfaces';
type Command =
'foo0'
| 'foo1'
| 'foo2'
| 'foo3'
| 'foo4'
| 'foo5'
| 'foo6'
| 'foo7'
| 'foo8'
@marcj
marcj / memoize.ts
Created January 22, 2022 01:00
memoize jit
import { BenchSuite } from '../bench';
const memoize = require('memoizee');
function memoizeWithJIT(fn: Function, options: { stackSize: number } = { stackSize: 10 }): Function {
const stacks: string[] = [];
const variables: string[] = [];
const argNames: string[] = [];
for (let a = 0; a < fn.length; a++) {
@marcj
marcj / typetype.ts
Created September 3, 2021 00:33
stack based scripting language for runtime TypeScript reflection and validation
enum OP {
string = 0,
number = 1,
boolean = 2,
object = 3,
function = 4,
array = 5,
date = 6,
class = 7,
interface = 8,
#!/usr/bin/env ts-node-script
import 'reflect-metadata';
import { Application, onServerMainBootstrap } from '@deepkit/framework';
import { injectable, InjectorContext } from '@deepkit/injector';
import { t } from '@deepkit/type';
import { AppModule, AppModuleConfig } from '@deepkit/app';
import { ClassType } from '@deepkit/core';
import { eventDispatcher } from '@deepkit/event';
type Options = { exchange: string, routingKey: string, queue: string };