Skip to content

Instantly share code, notes, and snippets.

View nobu-sh's full-sized avatar
🏓
Pong! 20ms

Nobu nobu-sh

🏓
Pong! 20ms
  • East Moline, Illinois
  • 02:24 (UTC -05:00)
View GitHub Profile
@nobu-sh
nobu-sh / is_installed.sh
Created June 22, 2021 16:01 — forked from JamieMason/is_installed.sh
Check if a program exists from a bash script.Thanks to twitter.com/joshnesbitt and twitter.com/mheap for the help with detecting npm packages.
#!/bin/bash
# Functions ==============================================
# return 1 if global command line program installed, else 0
# example
# echo "node: $(program_is_installed node)"
function program_is_installed {
# set to 1 initially
local return_=1
@nobu-sh
nobu-sh / ecosystem.config.json
Created September 22, 2021 23:17 — forked from WebSofter/ecosystem.config.json
Run laravel artisian serve script via pm2
{
"apps": [{
"name": "laravel-app",
"script": "artisan",
"args": ["serve", "--host=0.0.0.0", "--port=3333"],
"instances": "1",
"wait_ready": true,
"autorestart": false,
"max_restarts": 1,
"interpreter" : "php",
@nobu-sh
nobu-sh / Pixelit.ts
Created October 23, 2021 20:09
Typescript version of giventofly's pixelit
type Color = [number, number, number]
interface Config {
drawTo?: HTMLCanvasElement
drawFrom?: HTMLImageElement
scale?: number
palette?: Color[]
maxHeight?: number
maxWidth?: number
}
@nobu-sh
nobu-sh / EventEmitter.js
Created January 4, 2022 03:15
Typescript & Javascript EventEmitter
// Javascript EventEmitter Polyfill by [Nobu](https://github.com/NobUwU)
export class EventEmitter {
constructor(max = 25) {
this._listeners = new Map()
this.max = max
}
// Override toString/name Methods
static get [Symbol.toStringTag]() {
@nobu-sh
nobu-sh / Database.ts
Last active February 15, 2022 00:15
Simple NodeJS JSON Database.
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
import { dirname, resolve } from 'path'
export class Store<T extends Record<any, any>> {
protected readonly aPath: string
protected readonly data: T
constructor(path: string) {
this.aPath = resolve(__dirname, path)
if (!existsSync(this.aPath)) {