Skip to content

Instantly share code, notes, and snippets.

View adamAfro's full-sized avatar
🎭

Adam adamAfro

🎭
View GitHub Profile
@adamAfro
adamAfro / filecaller.js
Last active March 26, 2021 09:51
Pobiera plik z danej ścieżki albo z pamięci wewnętrznej „local storage”
/**
* https://github.com/adamAfro
* test
*/
export default class FileCaller {
/**
* gets file from web or indexed db
*/
static getAsString(path, version = 1) {
@adamAfro
adamAfro / particle.css
Created March 30, 2021 11:47
Prosta animacja atomu wokół jakiegoś tekstu
.particle {
display: inline-block;
position: relative; padding: 2em 5em 2em 1em;
overflow: hidden;
} .particle::after { content: ""; /* red ball */
display: block; border-radius: 100%; width: 0; height: 0; padding: 2em;
position: absolute; top: calc(50% - 2em); right: 0; z-index: 2;
@adamAfro
adamAfro / Github auth.mjs
Created April 23, 2021 15:07
Github app authorization adapted from Sergey Dubovyk article
/* Pushes issue to github repository
*
* Original: https://medium.com/@knidarkness/creating-a-github-app-with-node-js-3bda731d45b9
* Reference: https://github.com/octokit/request.js/#authentication
* Reporistories: https://github.com/octokit/app.js/
* Reporistories: https://github.com/octokit/auth-app.js/
*
* After installing deps and having .env file; this file may be run with: $ node auth.mjs
*/
@adamAfro
adamAfro / gapi-init.js
Created April 26, 2021 17:00
Google API init
function initAPI(window, { apiKey, clientId }) {
let doc = window.document;
return new Promise((resolve, reject) => {
const URL = "https://apis.google.com/js/api.js";
let apiTag = doc.querySelector(`script[src="${URL}"]`);
if (!apiTag) {
@adamAfro
adamAfro / index.mjs
Last active September 8, 2021 09:10
Skrypt do rysowania zestawu kół zębatych (bez kolizji)
export const Meta = {
title: "SVGear",
purpose: "making gearset in SVG with correct speed ratio",
limitations: [
"does not account for collisons: it just applies correct speed"
]
}; export default class Gear {
@adamAfro
adamAfro / Database.js
Created July 1, 2021 08:51
Indexed DB wrapper
class Database {
static get name() { return "maszynopis" }
/* Database structure is defined here */
static structurize(indexedDB) {
let store = indexedDB.createObjectStore("documents", { keyPath: "path" });
store.createIndex("path", "path", { unique: true });
@adamAfro
adamAfro / Express Strategies.js
Last active August 26, 2021 15:43
Making Express JS strategies for different roles
const Meta = {
author: "adamAfro",
title: "Express'Strategies",
purpose: "making strategies for different roles",
usage: "copy&paset and write how paths should or not"
+ " be handled for certain roles",
inspiration: "https://stackoverflow.com/a/32032705/13851998"
}
let strategies = {
@adamAfro
adamAfro / epub-w|pandoc.sh
Created October 9, 2021 13:31
making epub from given files
#!/bin/bash
# tworzenie pliku epub z danych dokumentów
T="Notatki" # tytuł
# style.css - plik ze stylami
# cover.jpg - okładka
F="zapiski"/* # folder z dokumentami
@adamAfro
adamAfro / sync.sh
Created October 17, 2021 10:41
sync 2 folders
#!/bin/bash
# Npdst.: https://unix.stackexchange.com/a/203854
# Umieszcza nowsze wersje plików i usuwa te których nie ma
d1="/home/adam/Dokumenty/abc/A"
d2="/home/adam/Dokumenty/abc/B"
# -avu - sys.attr.; verbose; leave the newest;
@adamAfro
adamAfro / headings.js
Last active November 14, 2021 12:24
Makes nodes hierarchy based on headings (h1,h2, ...)
class Section {
constructor({ depth = 0, owner = null } = {}) {
this.depth = depth, this.owner = owner;
this.nodes = [], this.sections = [];
}
}
let collection = [];