Skip to content

Instantly share code, notes, and snippets.

Avatar

Amir Arad amir-arad

  • Tel-aviv, Israel
View GitHub Profile
@amir-arad
amir-arad / snippet.js
Created September 13, 2022 18:43
download pgotobucket gallery
View snippet.js
/*
To use this:
1. paste the following code in chrome developer tools
*/
const { downloadZip } = await import(
"https://cdn.jsdelivr.net/npm/client-zip/index.js"
);
async function allImgs() {
const res = new Set();
@amir-arad
amir-arad / README.md
Created July 22, 2022 18:53
save/load feature for colyseus schema objects
View README.md

I'm adding a save/load feature to my WIP game and thought someone might find this small module useful

example usage:

const saveGameData = new SaveGame(); // make a custom schema for saved games data
... /* add all state objects from your game manager to saveGameData */
const serialized = await schemaToString(saveGameData);
... /* save to file, read from file etc. */
const loadedGameData: SaveGame = await stringToSchema(SaveGame, serialized );
... /* take game state object from loadedGameData into your game manager */
@amir-arad
amir-arad / definitions.json
Created January 19, 2022 12:12
rabbitMQ test setup
View definitions.json
{
"users": [
{
"name": "test",
"password": "test",
"tags": "administrator"
}
],
"vhosts": [
{
@amir-arad
amir-arad / convert.js
Created November 28, 2021 11:36
convert folder of markdown files to google docs in windows
View convert.js
const fs = require('fs');
const path = require('path');
var execSync = require('child_process').execSync;
const getAllFiles = function (dirPath, arrayOfFiles) {
files = fs.readdirSync(dirPath);
arrayOfFiles = arrayOfFiles || [];
files.forEach(function (file) {
@amir-arad
amir-arad / meckano.js
Created October 31, 2021 16:05
meckano monthly report clock faker
View meckano.js
const endTime = [];
const WORK_DAY_TIME_RANGE = {
half: {
min: 450,
max: 550
},
full: {
min: 540,
max: 660
}
@amir-arad
amir-arad / gist:ec7c286ff59be2621ecff592f4980409
Created August 3, 2021 16:13
a typescript map that generates default values if none exists
View gist:ec7c286ff59be2621ecff592f4980409
/**
* a map that generates default values if none exists
*/
export class MagicMap<K,V> extends Map<K,V> {
constructor(private defVal: () => V){
super();
}
has = (key:K) => true;
get = (key:K): V => {
View lines-data-collector.ts
// originally copied from https://gist.github.com/amir-arad/3c140b3c44b81dcc1ec108e109355c27
export type LineData = {
name: string;
y: number[];
x: number[];
};
export type GraphPointInput = {
annotate: (t: string) => unknown;
@amir-arad
amir-arad / ploty-graph-builder.ts
Created November 22, 2020 09:10
ploty graph builder
View ploty-graph-builder.ts
export type LineData = {
name: string;
y: number[];
x: number[];
};
export type GraphPointInput = {
annotate: (t: string) => unknown;
addtoLine: (n: string, v: number) => unknown;
};
export class PlotlyGraphBuilder {
@amir-arad
amir-arad / Starwards-CLA.md
Last active July 2, 2020 08:42 — forked from merqurio/CLA.md
Starwards CLA
View Starwards-CLA.md

Contributor License Agreement

The following terms are used throughout this agreement:

  • You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.
  • Starwards - a project whose digital assets are stored under github's starwards organization (https://github.com/starwards), owned by Amir Arad.
  • Project - is an umbrella term that refers to any and all Starwards's projects.
  • Contribution - any type of work that is submitted to a Project, including any modifications or additions to existing work.
  • Submitted - conveyed to a Project via a pull request, commit, issue, or any form of electronic, written, or verbal communication with Starwards's contributors or maintainers.

1. Grant of Copyright License.

@amir-arad
amir-arad / make-key.js
Created May 7, 2020 06:47
deterministic RSA keys
View make-key.js
const forge = require('node-forge');
const rsa = forge.pki.rsa;
function fix (str) {
return str.replace(/\r/g, '') + '\n'
}
exports.makeKey = function makeKey(id){
const prng = {
getBytesSync(_length){
const _id = '_' + id;
return {