Skip to content

Instantly share code, notes, and snippets.

View Krabaton's full-sized avatar
:dependabot:
Working

Yuriy Kuchma Krabaton

:dependabot:
Working
View GitHub Profile
@Krabaton
Krabaton / -5-ipynb.ipynb
Created August 10, 2023 14:59
Копія записника "Заняття 5. Похідні. Диференційні рівняння. Графіки функцій.ipynb"
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Krabaton
Krabaton / 0001_createsuperuser.py
Created November 28, 2022 13:58 — forked from inirudebwoy/0001_createsuperuser.py
Django 1.7+ migration for creating superuser
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations
from django.contrib.auth.admin import User
def create_superuser(apps, schema_editor):
superuser = User()
superuser.is_active = True
@Krabaton
Krabaton / nodejs-tcp-example.js
Created August 18, 2022 17:09 — forked from tedmiston/nodejs-tcp-example.js
Node.js TCP client and server example
/*
In the node.js intro tutorial (http://nodejs.org/), they show a basic tcp
server, but for some reason omit a client connecting to it. I added an
example at the bottom.
Save the following server in example.js:
*/
var net = require('net');
@Krabaton
Krabaton / esm-package.md
Created May 9, 2021 01:59 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@Krabaton
Krabaton / gist:f19188373a2adfe72d79d3b8785e3c10
Created March 8, 2021 21:06 — forked from jsumners/gist:e6b5d0a699f16ba980a3
Introduction to Sequelize Migrations

What are Migrations

Just like how we use Git to version control source code, we use migrations to manage the state of our database schemas.

I'm not really sure what that means...

Imagine you're working on project with another developer, and you're both tasked with creating a specific part of an event planning application. Let's say you are in charge of creating the Users and your friend is going to create the Events.

Let's say you and your friend divided the work in a way so that neither of you will have to to use each other's code to finish your tasks. While you're working on your part of the application, you only really need to touch the Users table when you are working with the database.

Creating models and migrations

@Krabaton
Krabaton / pug.md
Created November 22, 2020 18:17 — forked from neretin-trike/pug.md
Туториал по HTML препроцессору Pug (Jade)
@Krabaton
Krabaton / app.js
Created October 7, 2020 12:21
Upload formidable
const createError = require('http-errors')
const express = require('express')
const path = require('path')
const fs = require('fs').promises
const formidable = require('formidable')
const app = express()
const uploadDir = path.join(process.cwd(), 'uploads')
const storeImage = path.join(process.cwd(), 'images')
@Krabaton
Krabaton / app.js
Created October 7, 2020 12:18
Upload Multer
const createError = require('http-errors')
const express = require('express')
const path = require('path')
const fs = require('fs').promises
const app = express()
const multer = require('multer')
const uploadDir = path.join(process.cwd(), 'uploads')
const storeImage = path.join(process.cwd(), 'images')
const storage = multer.diskStorage({
@Krabaton
Krabaton / node-setup-pm2-nginx.md
Created June 16, 2018 12:05 — forked from tomysmile/node-setup-pm2-nginx.md
Setup NodeJS Production with PM2, Nginx in Ubuntu 16.04

How To Set Up a Node.js Application for Production on Ubuntu 16.04

with PM2 & Nginx

Create User

as a root, run below commands on server:

# adduser tomy
There have been proposals about exposing these variables through import.meta, but for now, you need a hacky workaround that I found here:
// expose.js
module.exports = {__dirname};
// use.mjs
import expose from './expose.js';
const {__dirname} = expose;
In Node.js 10 there's an alternative that doesn't require creating multiple files: