Skip to content

Instantly share code, notes, and snippets.

import http from 'http';
import httpProxy from 'http-proxy';
// Create a proxy server with custom application logic
const proxy = httpProxy.createProxyServer({});
// Create your server that makes an operation that waits a while
// and then proxies the request
http.createServer((req, res) => {
// Modify headers
@dentropy
dentropy / install.sh
Created January 30, 2024 04:47 — forked from shkarupa-alex/install.sh
Ubuntu 22.04 + Cuda
# Prioritize NVIDIA packages
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-ubuntu2204.pin
sudo mv cuda-ubuntu2204.pin /etc/apt/preferences.d/cuda-repository-pin-600
# Fetch NVIDIA keys
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/3bf863cc.pub
# Add NVIDIA repos
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/ /"
@dentropy
dentropy / index.js
Created September 13, 2023 10:19
better-sqlite3 demo
import sqlite from 'better-sqlite3';
let populate_data = `
-- Create the 'customers' table
CREATE TABLE IF NOT EXISTS customers (
customer_id INTEGER PRIMARY KEY,
first_name TEXT,
last_name TEXT,
email TEXT
);
@dentropy
dentropy / Load Mnemonic into EthersJS using DOTENV.md
Last active July 9, 2023 01:54
Load Mnemonic into EthersJS using DOTENV
@dentropy
dentropy / bad-md-processor.js
Created April 13, 2023 05:11
bad-md-processor.js
import sqlite3 from 'sqlite3';
import fs from 'node:fs/promises'
import { glob } from 'glob'
import {fromMarkdown} from 'mdast-util-from-markdown'
import {frontmatter} from 'micromark-extension-frontmatter'
import {frontmatterFromMarkdown, frontmatterToMarkdown} from 'mdast-util-frontmatter'
import { syntax } from 'micromark-extension-wiki-link'
import * as wikiLink from 'mdast-util-wiki-link'
// const db = new sqlite3.Database(':memory:');
@dentropy
dentropy / delete_all_sqlite_tables.py
Created April 13, 2023 03:00
SQLAlchemy Delete all tables in database
from sqlalchemy import create_engine, MetaData
import os
# set up the connection to the database
engine_path = "sqlite+pysqlite:///" + "/".join(os.getcwd().split("/")) + "/scraped_data.db"
engine = create_engine(engine_path)
conn = engine.connect()
# get all table names
meta = MetaData()
@dentropy
dentropy / docker-compose.yml
Last active August 4, 2023 08:35
Second postgres docker-compose
version: '3.1'
services:
db:
image: postgres
container_name: postgres
restart: always
environment:
POSTGRES_USER: postgres
@dentropy
dentropy / postgres2.yml
Last active August 4, 2023 08:36
Postgres docker-compose
version: '3.1'
services:
db:
image: postgres
container_name: postgres2
restart: always
environment:
POSTGRES_USER: postgres
# REMEMBER TO CHANGE THIS TO APP YOU WANT PASSWORD FOR
# App name can be found in umbrel-app.yml for example ./mediagoblin/umbrel-app.yml
app=mediagoblin
UMBREL_ROOT="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/..)"
# UMBREL_ROOT when umbrel installed on user dentropy is /home/dentropy/umbrel/app-data
app_entropy_identifier="app-${app}-seed"
derive_entropy () {
# Make sure we use the seed from the real Umbrel installation if this is