Skip to content

Instantly share code, notes, and snippets.

View EarlGeorge's full-sized avatar
💭
open for offer

გიორგი George Dav EarlGeorge

💭
open for offer
View GitHub Profile
@EarlGeorge
EarlGeorge / obs.js
Created May 25, 2019 14:38 — forked from mpj/obs.js
const delay = require('delay')
async function* makeCountingObservable() {
let count = 0
while(true) {
if (count > 4) return
await delay(1000)
yield count++
}
}
const counter = makeCountingObservable()
@EarlGeorge
EarlGeorge / README.md
Created February 13, 2021 12:21 — forked from cjhin/README.md
D3 Day/Week/Month Line Chart

D3 Time Series Day/Week/Month

Wanted to create a (daily) time series chart with automatic rollups to weekly/monthly lines AND nice transitions

Solution

The solution I ended up going with is a bit of an optical illusion.

All three views are technically backed by "daily" data.

@EarlGeorge
EarlGeorge / .block
Created February 13, 2021 12:28 — forked from mbostock/.block
Stacked Bar Chart
license: gpl-3.0
redirect: https://beta.observablehq.com/@mbostock/d3-stacked-bar-chart
@EarlGeorge
EarlGeorge / myscript.sh
Created February 13, 2021 12:29 — forked from bradtraversy/myscript.sh
Basic Shell Scripting
#! /bin/bash
# ECHO COMMAND
# echo Hello World!
# VARIABLES
# Uppercase by convention
# Letters, numbers, underscores
NAME="Bob"
# echo "My name is $NAME"
const crypto = require('crypto');
function decryptWithPrivateKey(privateKey, encryptedMessage) {
return crypto.privateDecrypt(privateKey, encryptedMessage);
}
function decryptWithPublicKey(publicKey, encryptedMessage) {
@EarlGeorge
EarlGeorge / session.js
Last active May 28, 2021 18:01
Session data is stored server-side, and using session ID inside cookie for users in browser.. using MongoDB - express !
const express = require("express");
const mongoose = require("mongoose");
const session = require("express-session");
const MongoStore = require("connect-mongo")(session);
// Create the Express application
var app = express();
const dbString = "mongodb://localhost:27017/db";
@EarlGeorge
EarlGeorge / issueJWT.js
Last active May 28, 2021 18:07
JWT Tokens
const base64url = require("base64url");
const crypto = require("crypto");
const signatureFunction = crypto.createSign("RSA-SHA256");
const verifyFunction = crypto.createVerify("RSA-SHA256");
const fs = require("fs");
/**
* ISSUANCE
**/
@EarlGeorge
EarlGeorge / background.js
Created October 17, 2021 19:37 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});
@EarlGeorge
EarlGeorge / promise_monad.md
Created July 29, 2022 08:28 — forked from VictorTaelin/promise_monad.md
async/await is just the do-notation of the Promise monad

async/await is just the do-notation of the Promise monad

CertSimple just wrote a blog post arguing ES2017's async/await was the best thing to happen with JavaScript. I wholeheartedly agree.

In short, one of the (few?) good things about JavaScript used to be how well it handled asynchronous requests. This was mostly thanks to its Scheme-inherited implementation of functions and closures. That, though, was also one of its worst faults, because it led to the "callback hell", an seemingly unavoidable pattern that made highly asynchronous JS code almost unreadable. Many solutions attempted to solve that, but most failed. Promises almost did it, but failed too. Finally, async/await is here and, combined with Promises, it solves the problem for good. On this post, I'll explain why that is the case and trace a link between promises, async/await, the do-notation and monads.

First, let's illustrate the 3 styles by implementing

@EarlGeorge
EarlGeorge / ProviderComposer.tsx
Created November 2, 2022 17:34 — forked from thebinaryfelix/ProviderComposer.tsx
Component for composing providers in React v18 with Typescript
export interface IProviderComposerProps extends React.PropsWithChildren {
/**
* Providers list
* */
with: React.FC<React.PropsWithChildren>[]
}
const ComposerFragment: React.FC<React.PropsWithChildren> = ({
children,
}): JSX.Element => <>{children}</>