Skip to content

Instantly share code, notes, and snippets.

View WORMSS's full-sized avatar

WORMSS WORMSS

View GitHub Profile
@WORMSS
WORMSS / express-upload-multer-example
Created July 7, 2017 12:32
Example code for uploading a file with express and multer
const express = require("express");
const multer = require("multer");
const upload = multer({"dest": "./mult"});
const app = express();
app.get("/", indexHandler);
app.post("/save", upload.single("fileField"), saveHandler);
@WORMSS
WORMSS / types.d.ts
Last active December 1, 2020 13:26
Typescript: My advanced types I don't want to lose
type Optional<T, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
type AllOrNothing<T> = T | Partial<Record<keyof T, never>>;
type OnlyOne<T> = {
[K in keyof T]: (
Required<Pick<T, K>> & Partial<Record<Exclude<keyof T, K>, never>>
)
}[keyof T];
type Test = {
@WORMSS
WORMSS / gitcommands.md
Last active October 20, 2021 10:18
Git Commands I usually forget but need maybe once every 2 years

Git Get Remote Sha:

$ git fetch origin <sha>

Git Octopus merge staging:

Make sure the staging area is how you want the commit to be

$ git write-tree
@WORMSS
WORMSS / ApiBuilder.ts
Last active March 15, 2022 12:50
Mini Api Builder
type URLSearchParamsInit = ConstructorParameters<typeof URLSearchParams>[0];
type ApiFormatMap = {
arrayBuffer: ArrayBuffer;
text: string;
json: object;
formData: FormData;
blob: Blob;
stream: ReadableStream<Uint8Array>;
response: Response;
};
@WORMSS
WORMSS / ws.js
Last active June 26, 2023 08:59 — forked from tabjy/ws.js
WebSocket from scratch. In Node.js
const http = require('http')
const crypto = require('crypto')
const server = http.createServer((req, res) => {
console.log('got request', req.url)
res.writeHead(200, { 'Content-Type': 'text/plain' })
res.end('okay')
})
server.on('upgrade', function (req, socket) {
@WORMSS
WORMSS / battery-highest-value.ic10
Last active May 17, 2024 07:07
Stationeers Quick Little Patterns
alias Counter r0
alias CurrentValue r1
alias KnownHighest r2
alias KnownHighestValue r3
alias Housing db
s Housing Setting -1
reset:
move Counter 0