Skip to content

Instantly share code, notes, and snippets.

View iNerV's full-sized avatar
❄️
Winter is coming

Vladimir Voytenko iNerV

❄️
Winter is coming
View GitHub Profile
@nalgeon
nalgeon / 00_npd.md
Created July 29, 2020 13:00
Определить самозанятого по ИНН

Определить самозанятого по ИНН

В поддержку «Дадаты» иногда обращаются с вопросом «как проверить, является ли физлицо самозанятым». Налоговая служба не предоставляет открытых данных по самозанятым, поэтому такого сервиса нет в «Дадате».

Но можно воспользоваться API налоговой. Мы подготовили примеры, как это сделать на самых популярных языках — Python, PHP и JavaScript.

API налоговой бесплатное, но используете его вы на свой страх и риск. Никто не гарантирует, что оно будет работать корректно и стабильно.

Пример ответа API налоговой, если ИНН принадлежит самозанятому:

@just-boris
just-boris / debounce.js
Created May 31, 2020 12:16
small debounce implementation without lodash
export const DEBOUNCE_DEFAULT_DELAY = 200;
export default function debounce(func, delay = DEBOUNCE_DEFAULT_DELAY) {
let timeout;
return function(...args) {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(() => {
import Vue from 'vue';
import getScrollbarWidth from "@modules/utils/getScrollbarWidth.js";
import { getDocument, getWindow } from "@modules/utils/dom.js";
const window = getWindow();
const document = getDocument();
const mobileWidth = parseInt(
window
.getComputedStyle(document.documentElement)
@acutmore
acutmore / README.md
Last active January 21, 2024 20:30
Emulating a 4-Bit Virtual Machine in (TypeScript\JavaScript) (just Types no Script)

A compile-time 4-Bit Virtual Machine implemented in TypeScript's type system. Capable of running a sample 'FizzBuzz' program.

Syntax emits zero JavaScript.

type RESULT = VM<
  [
    ["push", N_1],         // 1
    ["push", False],       // 2
 ["peek", _], // 3
@DavidWells
DavidWells / netlify.toml
Last active February 7, 2024 08:50
All Netlify.toml & yml values
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)
@rdmurphy
rdmurphy / aggregates.py
Created May 5, 2018 16:14
PostgreSQL specific Django Median aggregation function
from django.db.models import Aggregate, FloatField
class Median(Aggregate):
function = 'PERCENTILE_CONT'
name = 'median'
output_field = FloatField()
template = '%(function)s(0.5) WITHIN GROUP (ORDER BY %(expressions)s)'
@DreaMinder
DreaMinder / A Nuxt.js VPS production deployment.md
Last active October 11, 2023 11:33
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

@peketamin
peketamin / django_orm_when_case_f_example.py
Created January 24, 2018 03:54
Django ORM: When, Case, F (keyword: zero division error)
from django.db.models import F, Case, When, FloatField
from myapp import models
md = models.MyModel.objects.filter(pk=3).annotate(pr=Case(When(price__gte=40., then=F('price') * 10), default=F('price') / 10, output_fields=FloatField())).first()
In [27]: md.price
Out[27]: 40.7424047560126
In [29]: md.pr
Out[29]: 407.424047560126
@zmts
zmts / tokens.md
Last active May 2, 2024 15:03
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@asyncee
asyncee / method_chaining.py
Created March 23, 2016 15:32
Method chaining in python example
import copy
from collections import namedtuple, Sequence
Item = namedtuple('Item', 'name, price')
items = [
Item('apple', 10.0),
Item('banana', 12.0),
Item('orange', 8.0),