Skip to content

Instantly share code, notes, and snippets.

View 7pulse's full-sized avatar
🏠
Working from home

Borislav Godumov 7pulse

🏠
Working from home
View GitHub Profile
@7pulse
7pulse / CreatingElements.js
Created October 31, 2022 16:24
function for creating HTML elements dynamically
function e(type, attributes, ...children) {
const el = document.createElement(type);
Object.entries(attributes).forEach(entry => {
el.setAttribute(entry[0], entry[1]);
});
children.forEach(child => {
if (typeof child ==='string') {
el.appendChild(document.createTextNode(child));
} else {
el.appendChild(child);
let str = ")((()))()";
let count = 0;
function findMatch(str) {
if (str.includes("()")) {
let index = str.indexOf("()");
str = str.slice(0, index) + str.slice(index + 2);
count++;
findMatch(str);
} else {
@7pulse
7pulse / api.js
Created June 10, 2023 18:40
JavaScript Fetcher Function (with documentation from chatGPT ^^)
/**
* Performs an HTTP request with the specified method, URL, and optional data.
*
* @param {string} method - The HTTP method to be used for the request.
* @param {string} url - The URL to which the request will be sent.
* @param {object} [data] - The data to be sent with the request body. It should be in JSON format.
* @throws {Error} If an error occurs during the request or if the response status is not in the 200-299 range.
*/
const fetcher = async (method, url, data) => {
const options = {
{
// Editor settings
"editor.fontSize": 14,
// "editor.lineHeight": 1.8,
"editor.fontFamily": "jetBrains Mono",
"workbench.startupEditor": "newUntitledFile",
"editor.fontLigatures": true,
"editor.renderLineHighlight": "gutter",
"workbench.editor.labelFormat": "short",
"editor.semanticHighlighting.enabled": false,