Skip to content

Instantly share code, notes, and snippets.

View ivanjeremic's full-sized avatar
💭
I may be slow to respond.

Ivan Jeremic ivanjeremic

💭
I may be slow to respond.
View GitHub Profile
@ivanjeremic
ivanjeremic / React_Context_Typescript_Snippet_VSCODE
Last active April 29, 2020 03:05
React_Context_Typescript_Snippet_VSCODE
{
"Context_Typescript": {
"prefix": "ctxts",
"body": [
"import React, { useReducer } from 'react';",
"",
"/* ***** */",
"/* Types */",
"/* ***** */",
"interface Props {",
Context-File Typescript: ctxts
const state = new Proxy(defaultState, {
set(target, value, reciver) {
switch (value) {
case "val":
document.getElementById(
"_6bb6g"
).textContent = `increment ${target.val} and ${target.val}`;
break;
case "val":
@ivanjeremic
ivanjeremic / html.ts
Last active February 24, 2023 07:29
html template literal
export function html(literals: { raw: any }, ...vars: any[]) {
let raw = literals.raw,
HTMLprecompiled = "",
i = 1,
len = arguments.length,
str,
variable;
while (i < len) {
str = raw[i - 1];
@ivanjeremic
ivanjeremic / remover
Created December 15, 2023 20:44
remove file in folder based on condition nodeJS
const fs = require("fs");
const path = require("path");
const directory = path.join(__dirname, "public", "images");
fs.readdir(directory, (error, files) => {
if (error) throw new Error("Could not read directory");
files.forEach((file) => {
const file_path = path.join(directory, file);