Skip to content

Instantly share code, notes, and snippets.

@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
@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>'
// },
@culttm
culttm / es7-async-await.js
Created March 19, 2018 12:56 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
@culttm
culttm / EntityBase.php
Created December 3, 2017 22:00 — forked from lelledaniele/EntityBase.php
symfony doctrine updatedAt createdAt updated_at created_at fields timestamp
<?php
namespace AppBundle\Mapping;
use Doctrine\ORM\Mapping as ORM;
use DateTime;
/**
* Class EntityBase
*