Skip to content

Instantly share code, notes, and snippets.

@zakcodez
zakcodez / Mathletics Hack Code
Last active October 29, 2023 10:30 — forked from ITHackCentral/Mathletics Hack Code
Use in Live Mathletics
var time = 60; var clock = 300; function TimeHack() {
setInterval(function Applytime() {
document.getElementsByClassName('timerLabel whiteTextWithShadow font-60 ng-binding')["0"].innerText = time; document.getElementsByClassName('timerLabel whiteTextWithShadow font-60 ng-binding')["0"].innerHtml = time;
document.getElementsByClassName('clockHand').rotate = clock;
}, 1);
}; function TimeHackm() {
setInterval(function Addtime() {
time = time + 1;
clock = clock + 6;
}, 1000);
@zakcodez
zakcodez / net-client.js
Last active December 9, 2021 11:23 — forked from sid24rane/net.js
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
const net = require("net");
// creating a custom socket client and connecting it....
const client = new net.Socket();
client.connect({
port: 2222
});
client.on("connect", () => {
@zakcodez
zakcodez / emitter.ts
Created November 6, 2021 07:36
An event emitter, with an event map
// Usage:
// interface FooEventMap {
// run: (arg1: string, arg2: number) => void;
// }
//
// class Foo extends Emitter<{ [K in keyof FooEventMap]: FooEventMap[K] }> {
// run() {
// this.emit("run", "First argument", 5);
// }
@zakcodez
zakcodez / zlib-gz-demo.ts
Created November 5, 2021 09:55
Gzip a file using the zlib module
import zlib from "zlib";
import fs from "fs";
import stream from "stream";
import { promisify } from "util";
import readline from "readline";
const pipe = promisify(stream.pipeline);
const { stdin, stdout, stderr } = process;
(async function () {
@zakcodez
zakcodez / uuid.js
Last active October 6, 2021 01:42
A JavaScript Guid / UUID generator (works on node and web)
function randomUUID() {
const GUID_STRUCTURE = "xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx";
const GUID_CHARACTERS = {
"x": "0123456789abcdef",
"M": "12345",
"N": "89ab"
}
const replaceCharacter = (character) => {
const characters = GUID_CHARACTERS[character];
@zakcodez
zakcodez / keys.js
Created October 6, 2021 01:17
A script to encrypt and decrypt data using RSA public and private keys
const crypto = require("crypto");
const fs = require("fs");
// helper
function writeFile(file, data, callback = () => { }) {
fs.writeFile(file, data, (error) => {
if (error) throw error;
callback();
});
}
@zakcodez
zakcodez / server.js
Last active September 18, 2021 05:11
A simple server using Node.js
const http = require("http");
const path = require("path");
const url = require("url");
const fs = require("fs");
const config = {
app: {
http: {
port: 80,
host: "0.0.0.0"
@zakcodez
zakcodez / parseArguments.js
Last active September 18, 2021 02:58
A script to parse arguments from an array
// Call with either an array of arguments such as
// ["--foo=bar", "--bar", "baz"]
// or from the process in Node: process.argv.slice(2);
function parseArguments(argv) {
const parsedArgs = {
_: [],
flags: {}
}
argv.forEach((argument) => {
@zakcodez
zakcodez / id.js
Created September 7, 2021 11:17
Simple ID generator
function generateId() {
const randomString = () => Math.random().toString(36).substring(2, 15);
const id = randomString() + randomString();
return id;
}