Skip to content

Instantly share code, notes, and snippets.

@culttm
culttm / cookie.js
Created August 11, 2021 06:45
Simple extract cookie method
@culttm
culttm / .dockerignore
Created June 4, 2021 10:51 — forked from ksmithut/.dockerignore
Node Docker Compose nodemon
node_modules
const reg = new RegExp('(/' + namespace + '/)(.*)');
const partUrl = url.split(reg)[2];
@culttm
culttm / tokens.md
Created January 15, 2021 08:14 — forked from zmts/tokens.md
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@culttm
culttm / custom-entity-not-found-exception-filter.md
Created November 28, 2020 18:59 — forked from gsusmonzon/custom-entity-not-found-exception-filter.md
Make NestJs returns 404 when EntityNotFoundError exception is thrown

Make NestJs returns 404 when EntityNotFoundError exception is thrown

When using findOrFail() or findOneOrFail() from typeORM, a 500 error is returned if there is no entity (EntityNotFoundError).

To make it returns a 404, use an exception filter as described in https://docs.nestjs.com/exception-filters .

file /src/filters/entity-not-found-exception.filter.ts

const load = async (i18n, component) => {
const messages = () => import('~/i18n/translations/' + i18n.locale + '/components/' + component);
const componentMessages = await messages();
i18n.setLocaleMessage(i18n.locale, {
...i18n.messages[i18n.locale],
testComponent: componentMessages.default
});
@culttm
culttm / webpack.tailwindcss.js
Created October 4, 2019 09:49
Webpack + tailwindcss
const purgecss = require('@fullhuman/postcss-purgecss')({
// Specify the paths to all of the template files in your project
content: [
'./src/**/*.html',
'./src/**/*.jsx',
// etc.
],
// Include any special characters you're using in this regular expression

Шпаргалка по консольным командам Git

Общее

Git — система контроля версий (файлов). Что-то вроде возможности сохраняться в компьютерных играх (в Git эквивалент игрового сохранения — коммит).

Любой файл в папке существующего репозитория может находиться или не находиться под версионным контролем (отслеживаемые и неотслеживаемые).

@culttm
culttm / example-mobile-menu.js
Last active October 7, 2018 18:06
Example for mobile menu
$(document).ready(function () {
var MenuApp = (function () {
var Menu = function (options) {
this.el = options.el;
this.trigger = options.trigger;
};
Menu.prototype.init = function () {
import Vue from 'vue'
import VueUniversalModal, { ModalWrapper } from 'vue-universal-modal'
Vue.use(VueUniversalModal);
Vue.component('ModalWrapper', ModalWrapper);
// this.$modals.open({
// component: {
// template: '<div>something like a DOM or the global vue component</div>'
// },