Skip to content

Instantly share code, notes, and snippets.

View Valexr's full-sized avatar
:octocat:
coding...

Alexander Volkov Valexr

:octocat:
coding...
View GitHub Profile
import { session } from '$app/stores';
import type { Writable } from 'svelte/store';
import { derived } from 'svelte/store';
interface User {
id: number;
login: string;
name: string;
}
@getflourish
getflourish / Import CustomElements from .html files.md
Last active February 22, 2024 08:50
Import CustomElements from .html files

Import CustomElements from .html files

This is the technical implementation of the idea and concept described in my article “Why don’t we use HTML to author web components?

Instead of using template literals, constructors and other specifics to define CustomElements, this is a proposal to just use standard HTML to define CustomElements.

The goal is to import CustomElements like this:

@GuiDev404
GuiDev404 / cookieParser.js
Created May 7, 2021 02:09
Simple cookie parser
function cookieParser() {
const cookieToQuery = document.cookie.replace(/; /g,'&');
const params = new URLSearchParams(cookieToQuery);
return [...params.entries()].map(([key,value])=> ({ key, value }))
}
// Hacky Rollup plugin to remove source maps from Svelte components compiled for SSR
const killSSRmaps = {
renderChunk(code) {
return {
code: code.replace(/,[\s\n]*map:\s*(["'])\{.+?\}\1/g, ""),
};
},
};
@slava-vishnyakov
slava-vishnyakov / readme.md
Last active April 12, 2024 06:24
How to upload images with TipTap editor
  1. Create a file Image.js from the source below (it is almost a copy of Image.js from tiptap-extensions except that it has a constructor that accepts uploadFunc (function to be called with image being uploaded) and additional logic if(upload) { ... } else { ... previous base64 logic .. } in the new Plugin section.
import {Node, Plugin} from 'tiptap'
import {nodeInputRule} from 'tiptap-commands'

/**
 * Matches following attributes in Markdown-typed image: [, alt, src, title]
 *
@qoomon
qoomon / conventional_commit_messages.md
Last active May 4, 2024 21:21
Conventional Commit Messages

Conventional Commit Messages

See how a minor change to your commit message style can make a difference.

Tip

Have a look at git-conventional-commits , a CLI util to ensure these conventions and generate verion and changelogs

Commit Message Formats

Default

@tomasevich
tomasevich / nginx_nodejs.md
Last active April 7, 2024 12:13
Сервер в связке Nginx + NodeJs

Сервер в связке Nginx + NodeJs

Данная пошаговая инструкция поможет освоить основы на простом примере

Для справки

Сервер поднимался на Debian 8 c характеристиками:

CPU - 1 ядро x 500 МГц

@zmts
zmts / tokens.md
Last active May 4, 2024 17:22
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

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

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@AtulKsol
AtulKsol / psql-error-fix.md
Last active April 10, 2024 07:41
Solution of psql: FATAL: Peer authentication failed for user “postgres” (or any user)

psql: FATAL: Peer authentication failed for user “postgres” (or any user)

The connection failed because by default psql connects over UNIX sockets using peer authentication, that requires the current UNIX user to have the same user name as psql. So you will have to create the UNIX user postgres and then login as postgres or use sudo -u postgres psql database-name for accessing the database (and psql should not ask for a password).

If you cannot or do not want to create the UNIX user, like if you just want to connect to your database for ad hoc queries, forcing a socket connection using psql --host=localhost --dbname=database-name --username=postgres (as pointed out by @meyerson answer) will solve your immediate problem.

But if you intend to force password authentication over Unix sockets instead of the peer method, try changing the following pg_hba.conf* line:

from

@noelboss
noelboss / git-deployment.md
Last active May 2, 2024 15:47
Simple automated GIT Deployment using Hooks

Simple automated GIT Deployment using GIT Hooks

Here are the simple steps needed to create a deployment from your local GIT repository to a server based on this in-depth tutorial.

How it works

You are developing in a working-copy on your local machine, lets say on the master branch. Most of the time, people would push code to a remote server like github.com or gitlab.com and pull or export it to a production server. Or you use a service like deepl.io to act upon a Web-Hook that's triggered that service.