Skip to content

Instantly share code, notes, and snippets.

@sertraline
sertraline / chart.js
Created January 27, 2025 19:54
chartjs doughnut with labels outside
// setup
const data = {
labels: [
'Improved Screening (15%)',
'Reduced Dependence (20%)',
'Efficient Decisions (15%)',
'Proactive Prevention (30%)',
'Other (Remaining Savings)',
],
datasets: [
@sertraline
sertraline / tax_id.tsx
Created December 5, 2024 13:42
Typescript European VAT IDs + imaskjs masks and country codes
export interface TaxRecord {
alpha2_code: string
mask: string
desc: string
example: string
}
export const TaxIdentifiers: TaxRecord[] = [
{
alpha2_code: 'AT',
@sertraline
sertraline / iso3166.tsx
Last active December 4, 2024 06:26
Typescript alpha2 + alpha3 country codes and phone codes ISO 3166
interface Alpha3Country {
a2_code: string
a3_code: string
label: string
phone: string
}
const Countries: Alpha3Country[] = [
{
label: 'Andorra',
#!/bin/bash
# Will be set to 1 by the SIGINT ignoring/postponing handler
declare -ig SIGINT_RECEIVED=0
# On <CTRL>+C or "kill -s SIGINT $$" set flag for later examination
function _set_SIGINT_RECEIVED {
SIGINT_RECEIVED=1
}
# Set to 1 if you want to keep bash running after handling SIGINT in a particular way
@sertraline
sertraline / Auth.py
Last active October 2, 2023 12:54
Django DRF session auth
# JWT токен не работает в SSR приложениях по типу NextJS/Sveltekit которые не могут передать на сторону сервера заголовки.
# Варианта два, передавать токен в кукисах или отказаться от токена. Это второй вариант решения
from rest_framework.decorators import api_view, authentication_classes
from rest_framework.response import Response
from rest_framework import status
from drf_yasg.utils import swagger_auto_schema
from drf_yasg import openapi
from django.contrib.auth import login
from ..serializers.Registration import RegistrationSerializer
@sertraline
sertraline / translate.js
Created November 19, 2021 07:24
Translate latin into cyrillic
const mapCyrillic = {
KeyQ: 'й',
KeyW: 'ц',
KeyE: 'у',
KeyR: 'к',
KeyT: 'е',
KeyY: 'н',
KeyU: 'г',
KeyI: 'ш',
KeyO: 'щ',
@sertraline
sertraline / PhoneMask.vue
Last active September 3, 2021 06:59
Vue+Vuetify phone mask w/o dependencies
<template>
<div>
<v-text-field
:ref="`input-mask-${identifier}`"
v-model="inputPhone"
outlined
dense
label="Номер телефона"
hide-details
@keydown="input"
@sertraline
sertraline / phonemask.js
Last active September 3, 2021 06:36
Pure javascript phone mask. Supports backspacing as well as selection backspacing.
export default class PhoneField {
constructor(
handler,
code = '+7',
mask = '(___)___-__-__',
placeholder = '_'
) {
this.handler = handler;
this.mask = code + mask;
this.code = code;
@sertraline
sertraline / kde_taskbar.sh
Created July 31, 2021 19:56
Remove KDE taskbar shadows
for WID in $(xwininfo -root -tree | sed '/"Plasma": ("plasmashell" "plasmashell")/!d; s/^ *\([^ ]*\) .*/\1/g'); do
xprop -id $WID -remove _KDE_NET_WM_SHADOW
done
@sertraline
sertraline / record.sh
Created April 8, 2021 21:08
AMD FFMPEG+VAAPI screen recording with microphone input
#!/bin/bash
# AMD + FFMPEG VAAPI screen+alsa+pulseaudio recording script
# In your home directory create .asoundrc with following contents:
# pcm.!default pulse
# ctl.!default pulse
# This allows alsa to use pulseaudio as the input device.
# Bind any hotkey to the script.
# Launch once - recording starts. Launch twice - recording stops.