Skip to content

Instantly share code, notes, and snippets.

@zakcodez
zakcodez / Mathletics Hack Code
Last active Nov 11, 2022 — forked from ITHackCentral/Mathletics Hack Code
Use in Live Mathletics
View Mathletics Hack Code
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 / emitter.ts
Created Nov 6, 2021
An event emitter, with an event map
View emitter.ts
// 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 Nov 5, 2021
Gzip a file using the zlib module
View zlib-gz-demo.ts
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 / keys.js
Created Oct 6, 2021
A script to encrypt and decrypt data using RSA public and private keys
View keys.js
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 / uuid.js
Last active Oct 6, 2021
A JavaScript Guid / UUID generator (works on node and web)
View uuid.js
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 / net-client.js
Last active Dec 9, 2021 — forked from sid24rane/net.js
Simple TCP Client and Server in Node.js (Covering all useful Properties & Methods)
View net-client.js
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 / parseArguments.js
Last active Sep 18, 2021
A script to parse arguments from an array
View parseArguments.js
// 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 / server.js
Last active Sep 18, 2021
A simple server using Node.js
View server.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 / id.js
Created Sep 7, 2021
Simple ID generator
View id.js
function generateId() {
const randomString = () => Math.random().toString(36).substring(2, 15);
const id = randomString() + randomString();
return id;
}