Skip to content

Instantly share code, notes, and snippets.

View icebob's full-sized avatar

Icebob icebob

View GitHub Profile
@guest271314
guest271314 / compiling_standalone.md
Last active April 9, 2024 08:48
Compiling a standalone executable using modern JavaScript/TypeScript runtimes

Compiling a standalone executable using modern JavaScript/TypeScript runtimes

We have the same code working using node, deno, and bun.

E.g.,

bun run index.js
#!/usr/bin/env python
"""
pip install tiktoken requests
export OPENAI_API_KEY=<redact>
chmod +x prepare-commit-msg
mv prepare-commit-msg .git/hooks/
"""
import math
@marxangels
marxangels / express-hot-reload.js
Last active September 10, 2023 03:59
A simple module-level hot-reload for my express web application with less than 200 lines of code.
import fs from 'fs'
import vm from 'vm'
import path from 'path'
/*
* cli command
* node --experimental-vm-modules express-hot-reload.js
*/
const ModuleCache = new Map()
@PabloSzx
PabloSzx / test-esm.mjs
Created August 12, 2021 16:45
Quick test Node.js ESM
// Using:
// globby@11.0.4
// chalk@4.1.2
import globby from 'globby';
import { dirname } from 'path';
import { fileURLToPath } from 'url';
import chalk from 'chalk';
async function main() {
@intech
intech / queue.js
Created May 2, 2021 15:33
Moleculer Middleware redis-smq
const { callbackify } = require("util");
const { GracefulStopTimeoutError } = require("moleculer").Errors;
const { Message, Producer, Consumer } = require("redis-smq");
const events = require("redis-smq/src/events");
module.exports = function QueueMiddleware() {
const producers = new Map();
const consumers = new Map();
function gracefulShutdown(broker, items) {
@intech
intech / grpc.mixin.js
Created March 29, 2021 16:42
Mixin for dynamic generates services and method gRPC from registry moleculer
"use strict";
const { MoleculerError } = require("moleculer").Errors;
const { Root, Namespace, Service, Method, Type, Field } = require("protobufjs");
const gRPC = require("grpc");
module.exports = {
name: "grpc",
settings: {
port: 50051,
@intech
intech / knex.middleware.js
Last active February 19, 2023 16:57
Moleculer middleware Knex
const Knex = require("knex");
const { MoleculerServerError } = require("moleculer").Errors;
// const saveAsyncStack = require('knex/lib/util/save-async-stack');
const { types } = require("pg");
types.setTypeParser(20, (value) => +value);
types.setTypeParser(1700, (value) => +value);
module.exports = function KnexMiddleware(options) {
options = {
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages
@icebob
icebob / docker-compose.yml
Last active November 1, 2023 06:02
Start K3S Cluster on Docker
version: '3'
services:
server:
image: "rancher/k3s:latest"
command: server
tmpfs:
- /run
- /var/run
privileged: true
@tobydeh
tobydeh / docker-compose.yml
Last active October 23, 2022 20:51
gitea 1.10, drone 1.6 and drone-runner-docker example using docker-compose
# Instructions
# 1. Update your /etc/hosts file...
# > 127.0.0.1 gitea drone
# 2. Run gitea + gitea-db and generate the oauth application
# > docker-compose -p gitea-drone up gitea gitea-db
# - Navigate to http://gitea:3000 to finish the installation and register a user
# - Create a oauth application as described here: https://docs.drone.io/installation/providers/gitea/
# - Set the Redirect uri to http://drone:8000/login
# 3. Update the docker-compose file with the client_id and client_secret
# 4. Fire up all of the services