Skip to content

Instantly share code, notes, and snippets.

View amir-arad's full-sized avatar

Amir Arad amir-arad

  • Tel-aviv, Israel
View GitHub Profile
@amir-arad
amir-arad / bluebird-ext.d.ts
Created November 21, 2016 18:53
an addition to the bluebird descriptors
import * as Bluebird from "@types/bluebird";
declare module "bluebird" {
/**
* Returns a promise that is resolved by a node style callback function.
*/
export function fromNode<T>(resolver: (callback: (err: any, result?: Bluebird<T>) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird<T>;
export function fromCallback<T>(resolver: (callback: (err: any, result?: Bluebird<T>) => void) => void, options?: Bluebird.FromNodeOptions): Bluebird<T>;
}
@amir-arad
amir-arad / lodash.d.ts
Last active January 11, 2022 17:24 — forked from albohlabs/lodash.d.ts
fixed to pass strict mode validation, plus some generic types here and there
// https://raw.githubusercontent.com/donnut/typescript-ramda/master/ramda.d.ts
// https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/master/lodash/lodash.d.ts
declare namespace fp {
interface Dictionary<T> {
[index: string]: T;
}
interface CurriedFunction1<T1, R> {
@amir-arad
amir-arad / vorpal.d.ts
Created February 9, 2018 08:34
WIP type descriptors for vorpal
// Type definitions for vorpal 1.12.0
// Project: https://github.com/dthree/vorpal
// Definitions by: Jim Buck <http://github.com/jimmyboh>, Amir Arad <greenshade@gmail.com>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="inquirer" />
/// <reference types="minimist" />
declare module "vorpal" {
import {ParsedArgs} from 'minimist';
@amir-arad
amir-arad / c_cpp_properties.json
Last active February 26, 2021 10:54
An opinionated EmptyEpsilon development setup for windows
{
"configurations": [
{
"name": "win32",
"includePath": [
"${workspaceFolder}/src",
"${workspaceFolder}/../SeriousProton/src",
"${workspaceFolder}/../SFML-2.5.1/include"
],
"browse" : {
@amir-arad
amir-arad / make-workflow.js
Created March 31, 2019 13:43
generate github actions workflow automatically for yarn monorepo
#!/usr/bin/env node
var fs = require('fs');
var path = require('path');
const moduleNames = fs.readdirSync(path.resolve(__dirname, '..', 'modules'), {withFileTypes:true}).filter(n => n.isDirectory()).map(n => n.name);
fs.writeFileSync(path.join(__dirname, 'main.workflow'), repoScript(moduleNames));
@amir-arad
amir-arad / make-key.js
Created May 7, 2020 06:47
deterministic RSA keys
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 {
@amir-arad
amir-arad / Starwards-CLA.md
Last active July 2, 2020 08:42 — forked from merqurio/CLA.md
Starwards CLA

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 / ploty-graph-builder.ts
Created November 22, 2020 09:10
ploty graph builder
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 {
// 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 / gist:ec7c286ff59be2621ecff592f4980409
Created August 3, 2021 16:13
a typescript map that generates default values if none exists
/**
* 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 => {