Skip to content

Instantly share code, notes, and snippets.

@scharf
scharf / DS_CDQ2A40-100DZ_de_DE.md
Last active April 16, 2024 07:51
DS_CDQ2A40-100DZ_de_DE

SMC

Expertise - Passion - Automation

{
"$schema": "https://json-schema.org/draft/2019-09/schema",
"title": "AssetAdministrationShellEnvironment",
"$id": "http://www.admin-shell.io/schema/json/v2.0.1",
"type": "object",
"required": [
"assetAdministrationShells",
"submodels",
"assets",
"conceptDescriptions"
@scharf
scharf / mypy-intellij.sh
Last active May 12, 2022 14:57
mypy wrapper to make the error links clickabe in pycharm/webstorm/intellij (jetbrains)
#!/bin/bash
PY_ROOT=$(cd "$(dirname "$0")";cd ../..; pwd)
MYPY_BIN=${PY_ROOT}/.venv/bin/mypy
basepath=`pwd`
OUTPUT=`$MYPY_BIN $*`
import { observable, makeObservable, autorun, runInAction } from 'mobx';
function assignValueToMember(self: object, memberName: string, version: number) {
console.log('\n');
// @ts-ignore
const dispose = autorun(() => console.log(`autorun ${memberName} == ${self[memberName]}`));
console.log(`assign ${memberName} = ${version}`);
runInAction(() => {
// @ts-ignore
self[memberName] = version;
@scharf
scharf / patch_invoke.py
Created March 2, 2022 23:00
Allow type annotation in the python invoke project
from unittest.mock import patch
from inspect import getfullargspec, ArgSpec
import invoke
def fix_annotations():
"""
Pyinvoke doesnt accept annotations by default, this fix that
Based on: https://github.com/pyinvoke/invoke/pull/606
import re
import xml.etree.ElementTree as ET
import sys
# from pprint import pprint
from collections import ChainMap
def xml_to_dict_recursive(root):
if len(root.getchildren()) == 0:
return {root.tag: root.text}
@scharf
scharf / pymongo-mypy-stubs.md
Last active October 27, 2020 17:54
pymongo mypy stubs
@scharf
scharf / MiniRouter.ts
Created October 19, 2018 10:43
Mini Router
import { reaction } from 'mobx';
import { Store } from '../store/Store';
// when parcel reloads the page, we have to unsubscribe the old listener...
let oldListener: any;
// this is inspired by https://hackernoon.com/how-to-decouple-state-and-ui-a-k-a-you-dont-need-componentwillmount-cc90b787aa37
// TODO this is way to simple!!!!!!
export class MiniRouter {
constructor(private readonly store: Pick<Store, 'view'>) {
@scharf
scharf / QueryStringParser.ts
Created May 25, 2018 16:48
Mongo Query String Parser
import { toDateOrNull } from '../toDate';
function substituteQuotedCharacters(inner: string) {
return inner.replace(/\\./g, function(s) {
switch (s[1]) {
case 'n':
return '\n';
case 't':
return '\t';
case 'r':
@scharf
scharf / toDate.ts
Created May 25, 2018 16:46
Parse Date
/**
* Tries to return a valid date or null. It can parse (valid) date strings as well as numbers.
* @param date a valid date or null
*/
/**
* Tries to return a valid date or null. It can parse (valid) date strings as well as numbers.
*
* @param val
* @param defaultValue
* @returns {any}