Skip to content

Instantly share code, notes, and snippets.

View dimon-durak's full-sized avatar

Димон Дурак dimon-durak

View GitHub Profile
@dimon-durak
dimon-durak / .gitignore
Created January 27, 2022 08:45 — forked from smoser/.gitignore
cloud-init ubuntu nocloud example with network config
*.img
*.raw
@dimon-durak
dimon-durak / javascript-useful-links.md
Created September 16, 2021 06:32 — forked from genadyp/javascript-useful-links.md
javascript (js) useful links
@dimon-durak
dimon-durak / .eleventy.js
Created September 16, 2021 06:24 — forked from shawn-sandy/.eleventy.js
FP-Pages
const fs = require("fs")
const htmlmin = require("html-minifier")
const pluginRss = require("@11ty/eleventy-plugin-rss")
const markdown = require("@shawnsandy/ideas/lib/markdown")
const image = require("@11ty/eleventy-img")
const CleanCSS = require("clean-css")
const eleventyNavigationPlugin = require("@11ty/eleventy-navigation")
const take = ("lodash.take")
@dimon-durak
dimon-durak / style.11ty.js
Created September 16, 2021 05:24 — forked from liamfiddler/style.11ty.js
SCSS + PostCSS pipeline for 11ty
// sass dependencies: `npm i -D sass`
const util = require('util');
const sass = require('sass');
const renderSass = util.promisify(sass.render);
// postcss dependencies: `npm i -D autoprefixer postcss precss`
const autoprefixer = require('autoprefixer');
const postcss = require('postcss');
const precss = require('precss');
const postcssProcessor = postcss([precss, autoprefixer]);
@dimon-durak
dimon-durak / gist:3eebe4fb7a5963bf9d38b570d8e19e4e
Created September 16, 2021 05:12 — forked from SteveALee/gist:0e78dff6040780720093a14ce3a6f0ba
Have browsers update when editing 11ty config file

By default 11ty devmode uses browsersync to reload webbrowsers whenever it regenerates pages to _site. It does this automatically when template files change.

However, the .eleventy.js file is only loaded when 11ty starts so if you edit shortcodes (say) you need to stop and restart 11ty.

The solution is to use nodemon to restart 11ty automatically when the config file changes. But then you need to use browser F5 to refresh. The solution to that is to get browsersync to reload the browsers To achieve that, the 11ty browsersync config option allows you to define a callback when browsersync is ready and you can add a browser reload call there.

Here's example code from music-practice-tools

@dimon-durak
dimon-durak / 11ty-parsing-post-collection-with-tags.md
Created September 16, 2021 05:12
11ty - Parsing posts collection with tags

11ty - Parsing posts collection with tags

My code to parse posts or any other collection in 11ty.

Result

  • Order of the posts gets reversed, sorting by date.
  • Date format normalized (d.m.y).
  • Description shortened to 105 characters.
  • Undefined or empty tags are ignored.
import { promises as fs } from "fs";
import * as path from "path";
import * as jsyaml from "js-yaml";
import { fileURLToPath } from "url";
import MarkdownIt from "markdown-it";
const mdit = new MarkdownIt({});
const __dirname = path.dirname(fileURLToPath(import.meta.url));
const srcdir = path.resolve(__dirname, "./src");
const builddir = path.resolve(__dirname, "./build");
@dimon-durak
dimon-durak / markdown-details-collapsible.md
Created September 16, 2021 04:53 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@dimon-durak
dimon-durak / psql-import-db-dump.md
Created September 16, 2021 04:52 — forked from pierrejoubert73/psql-import-db-dump.md
How to import a dump file in PSQL.

Open terminal.

Connect to psql:

psql -p 5433

I find it easier to delete and recreate the DB to which you want to import. So ensure the databse you want to delete is listed:

\l

When I went through Eliot's excellent tutorial, I decided to try to push forward with the latest-and-greatest version of Postgres to troubleshoot the directions with the newer version (the 64-bit Version 9.6.1.1 x64 Windows installer).

But first I had cleanup to do. I had mistakenly assumed that I was running postgresql under WSL and installed some packages. I removed them to make sure I didn't end up with collisions over Linux and Windows binaries sharing the same name in $PATH.

➜  ~ sudo apt-get remove postgresql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be REMOVED: