Skip to content

Instantly share code, notes, and snippets.

View kacem22's full-sized avatar
🎯
Focusing

kacem22

🎯
Focusing
View GitHub Profile
@kacem22
kacem22 / index.js
Created September 12, 2025 00:46 — forked from adrianhorning08/index.js
Find Key in JS
// Function to recursively search for the key
export function findKey(obj, keyToFind) {
try {
if (obj.hasOwnProperty(keyToFind)) {
return obj[keyToFind];
}
for (let key in obj) {
if (typeof obj[key] === "object" && obj[key] !== null) {
let result = findKey(obj[key], keyToFind);
@kacem22
kacem22 / spacePreviewImage.js
Created February 19, 2025 13:26 — forked from pketh/spacePreviewImage.js
Generates a bitmapped preview image of a space document
import controllers from './controllers.js'
import utils from '../utils.js'
import consts from '../consts.js'
import { createCanvas, loadImage, createImageData, CanvasRenderingContext2D, DOMMatrix, ImageData } from 'canvas'
import { polyfillPath2D } from 'path2d-polyfill'
import webp from '@cwasm/webp'
import moment from 'moment'
import _ from 'lodash'
import heicConvert from 'heic-convert'
@kacem22
kacem22 / Knex-Setup.md
Created May 4, 2024 13:36 — forked from NigelEarle/Knex-Setup.md
Setup Knex with Node.js

Knex Setup Guide

Create your project directory

Create and initialize your a directory for your Express application.

$ mkdir node-knex-demo
$ cd node-knex-demo
$ npm init
@kacem22
kacem22 / bunnycdn_api.js
Created March 28, 2024 16:44 — forked from erfg12/bunnycdn_api.js
BunnyCDN API PUT for NodeJS. Use startUploading function to start the uploading process of all files in a directory.
var request = require('request');
var fs = require('fs');
function uploadItem(item) {
console.log('uploading ' + item);
request({
method: 'PUT',
preambleCRLF: true,
postambleCRLF: true,
uri: 'https://storage.bunnycdn.com/newagetest//path/filename',
@kacem22
kacem22 / meta-seo.jade
Created February 25, 2024 21:43 — forked from pketh/meta-seo.jade
seo meta tags for social unfurling
// facebook open graph tags
meta(property="og:type" content="website")
meta(property="og:url" content=url)
meta(property="og:title" content=title)
meta(property="og:description" content=description)
meta(property="og:image" content=frog2x)
// twitter card tags (stack with og: tags)
meta(name="twitter:card" content="summary")
meta(name="twitter:site" content="@pketh")
@kacem22
kacem22 / macrolight list.json
Last active February 20, 2024 18:33 — forked from pketh/macrolight list.json
code language list to hihglight keywords when using https://github.com/xyzshantaram/macrolight
[
{"id": 1,"name": "txt"},
{"id": 2,"name": "c", "color": "#555555", "keywords": ["auto", "break", "case", "char", "const", "continue", "default", "do", "double", "else", "enum", "extern", "float", "for", "goto", "if", "int", "long", "register", "return", "short", "signed", "sizeof", "static", "struct", "switch", "typedef", "union", "unsigned", "void", "volatile", "while"]},
{"id": 3,"name": "c++", "color": "#f34b7d", "keywords": ["alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand", "bitor", "bool", "break", "case", "catch", "char", "char8_t", "char16_t", "char32_t", "class", "compl", "concept", "const", "consteval", "constexpr", "const_cast", "continue", "co_await", "co_return", "co_yield", "decltype", "default", "delete", "do", "double", "dynamic_cast", "else", "enum", "explicit", "export", "extern", "false", "float", "for", "friend", "goto", "if", "inline", "int", "long", "mutable", "namespace", "new", "noexcept", "not", "not_eq", "nullptr", "operator", "or", "or_eq", "private", "protected
@kacem22
kacem22 / state.js
Created July 14, 2023 01:19 — forked from dbisso/state.js
Simple state management in vanilla JS
function State() {
this.actions = {};
this.subscriptions = [];
this.history = [];
}
State.prototype.subscribe = function(element, action, callback) {
this.subscriptions[action] = this.subscriptions[action] || [];
this.subscriptions[action].push(function(data) {
callback.apply(element, data);