Skip to content

Instantly share code, notes, and snippets.

View sploders101's full-sized avatar

Shaun Keys sploders101

View GitHub Profile
@sploders101
sploders101 / netmask.js
Created December 29, 2018 22:47
Simple functions for performing netmask checks on an IP.
function IPBInt(ip) {
const iparr = ip.split(".");
let bip = 0n;
for(let i=0;i<iparr.length;i++) {
bip = bip << 8n;
bip += BigInt(iparr[i]);
}
return bip;
}
@sploders101
sploders101 / fileDrop.vue
Last active September 17, 2023 15:25
Vuetify file drop box (drag-n-drop enabled, no directory support, uses vuetify-loader)
<template>
<!-- Drop box -->
<div class="dropzone"
@dragover.prevent
@dragleave="dragleave"
@dragenter="dragenter"
@drop="drop"
ref="dropzone"
>
<!-- Box Label -->
@sploders101
sploders101 / events.d.ts
Last active October 30, 2019 16:01
Muuri 0.8.0 types
import Item from "./item";
import Muuri from ".";
// Type this!!!
export type DraggerEvent = any;
export interface EventListeners {
synchronize(): any;
layoutStart(items: Item[]): any;
layoutEnd(items: Item[]): any;
@sploders101
sploders101 / barcodeInput.vue
Created December 19, 2019 20:26
Barcode scanner input component [vue] [vuetify] [instascan]
<template>
<div>
<v-text-field
v-model="syncVal"
>
<template slot="append">
<v-tooltip top>
<template v-slot:activator="{ on }">
<v-btn
v-on="on"
@sploders101
sploders101 / stringifyParseCircular.ts
Created February 14, 2020 21:57
[JS] Circular reference deconstructor/reconstructor. Can be used to serialize objects with circular references
const rand = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
type CSValue = CSLiteral | CSRef;
type CSLiteral = string | number | boolean | null;
type CSRef = [string];
export function analyzeRefs(obj: any) {
const reference = new Map<object | any[], string>();
// Build reference table
@sploders101
sploders101 / download.js
Last active June 23, 2020 21:11
Simple function for downloading text
function downloadString(str, name) {
const elem = document.createElement("a");
elem.href = URL.createObjectURL(new Blob([str]));
elem.download = name;
elem.click();
}
@sploders101
sploders101 / MuuriGrid.vue
Last active August 18, 2020 08:45
Array-based muuri grid
<template>
<div
ref="muuriel"
class="muuri"
>
<div
class="muuri-item"
v-for="field in value"
:muurikey="field[muurikey]"
@sploders101
sploders101 / updateProxy.ts
Last active August 6, 2021 13:58
Example update proxy for electron
import http from "http";
import https from "https";
import {
AddressInfo,
} from "net";
import { URL } from "url";
const updateServer = "https://updates.yourserver.com/path/to/update/dir/without/trailing/slash";
const updateAuth = `Basic ${Buffer.from("username:password").toString("base64")}`
@sploders101
sploders101 / streamSplicer.ts
Created May 3, 2021 20:35
Readable stream to splice many different sequential streams into one
import {
Readable,
} from "stream";
export interface SpliceEntry {
size: number;
stream: Readable | Buffer;
}
export class StreamSplicer extends Readable {
[colors.bright]
black = "0x7f7f7f"
blue = "0x5c5cff"
cyan = "0x00ffff"
green = "0x00ff00"
magenta = "0xff00ff"
red = "0xff0000"
white = "0xffffff"
yellow = "0xffff00"