Skip to content

Instantly share code, notes, and snippets.

View Niedzwiedzw's full-sized avatar
🦀
providing safe API

Wojciech Niedźwiedź Niedzwiedzw

🦀
providing safe API
View GitHub Profile
# works for Pycharm Professional Edition 2017.3 as of 26.03.2018
# send thanks to niedzwiedzwo@gmail.com
1. Ctrl + alt + S (settings)
2. find `External Tools`
3. fill them up like this: https://ibb.co/bEpth7
3a.
Program: {pylint_path} # just `pylint` should be ok for most cases
#!/usr/bin/env python3
import typing as t
from os import listdir, environ, getcwd, mkdir
from os.path import split
from shutil import copyfile
from subprocess import check_output as run
from pprint import pprint
@Niedzwiedzw
Niedzwiedzw / JsonSerializable mixin
Last active November 12, 2019 17:35
A quick way to have your class be serializable to json in a nested way
from json import dumps
from copy import deepcopy
class JsonSerializable:
@staticmethod
def _to_json(item):
if isinstance(item, JsonSerializable):
return item.json
@Niedzwiedzw
Niedzwiedzw / AppModal.vue
Created February 8, 2021 14:15
Vue 3 self-closing modal
<template>
<button class="activator" @click="onButtonClick()">
{{ buttonText }}
</button>
<transition name="slide-fade">
<div class="modal" :class="{ show }" :key="show" v-if="show">
<div class="exit-button" @click="onCloseModal()">
X
</div>
<div class="content">
(() => {
const data = [{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}, {
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
(async() => {
const todos = [{
"userId": 1,
"id": 1,
"title": "delectus aut autem",
"completed": false
}, {
"userId": 1,
"id": 2,
"title": "quis ut nam facilis et officia qui",
@Niedzwiedzw
Niedzwiedzw / FillOverlay.vue
Created April 13, 2021 10:50
Vue 3 element overlay wrapper
<template>
<div class="FillOverlay" ref="element">
<slot class="overlay-content"></slot>
<div class="overlay" :style="currentOverlayStyle" :key="percent"></div>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, computed, onMounted } from "vue";
import { useInterval } from "../../composables/forms";
#!/usr/bin/env python3
from dataclasses import dataclass
import math
def dbg(val):
print(val)
return val
def to_degrees(rad: float) -> float:
// somewhere in your project, create a svelte-jsx.d.ts file and add this:
declare namespace svelte.JSX {
interface HTMLAttributes<T> {
onchecked?: () => void;
onunchecked?: () => void;
}
}
@Niedzwiedzw
Niedzwiedzw / TextOverflowWatcher.svelte
Created March 14, 2022 08:39
detects element's text overflow and fixes it
<script lang="ts">
import { LANGUAGE_CHANGED_EVENT } from '@/user-settings-store';
import { takeWhile, last } from 'lodash-es';
import { onMount } from 'svelte';
export let maxWidthPx = 99999;
export let marginPx = 8;
function textWidth(element: HTMLElement) {