Skip to content

Instantly share code, notes, and snippets.

View ryzokuken's full-sized avatar
⚔️
Fighting the borrow checker

Ujjwal Sharma ryzokuken

⚔️
Fighting the borrow checker
View GitHub Profile

Keybase proof

I hereby claim:

  • I am ryzokuken on github.
  • I am ryzokuken (https://keybase.io/ryzokuken) on keybase.
  • I have a public key ASBZT8DtcTWqN420ttPnntD5WB9sCtOA1zI6XOwa2kTucAo

To claim this, I am signing this object:

@ryzokuken
ryzokuken / README.md
Last active April 11, 2019 19:24
SkyNet
  1. Install TypeScript Compiler (npm install -g typescript)
  2. Compile (tsc simulation.ts -t "esnext" -m "commonjs")
  3. Run (node simulation.js)
  4. Profit
@ryzokuken
ryzokuken / merkle.js
Last active July 30, 2022 15:57
TypeScript Merkle Tree Implementation
const hash = require('easy-crypto/hash');
class MerkleTreeNodeGeneric {
compare(node) {
return this.hash === node.hash;
}
}
class MerkleTreeChildNode extends MerkleTreeNodeGeneric {
constructor(data) {
@ryzokuken
ryzokuken / crypto.md
Created October 8, 2018 09:00
Outline for the talk - State of Crypto in Node.js
  • Goals of the crypto module
  • "Why do I need crypto? I am already using TLS!"
    • Password encryption
    • User data encryption (with authentication)
    • Signing data
    • Using cryptographically-safe hashes
    • Crypto-safe random number generation
    • Interoperate with other crypto systems → WebCrypto
    • Maybe some one-slide examples
  • "Why crypto isn't simple" (Plug for simple-crypto / crypt)

Proposed method for bound prototype methods

Sample method, Collator.prototype.compare (https://tc39.github.io/ecma402/#sec-intl.collator.prototype.compare)

  1. Let collator be this value.
  2. If Type(collator) is not Object, throw a TypeError exception.
  3. If collator does not have an [[InitializedCollator]] internal slot, throw a TypeError exception.
  4. If collator.[[BoundCompare]] is undefined, then a. Let F be a new built-in function object as defined in 10.3.3.1. b. Set F.[[Collator]] to collator.
@ryzokuken
ryzokuken / README.md
Created May 23, 2018 05:11
A small gist that attempts to reproduce nodejs/node#20824

This is a small example that attemps to reproduce the error caused at nodejs/node#20824, possibly due to a race condition.

It seems like there are race conditions between the StreamPipe mechanism and HTTP/2 shutting down; on the HTTP/2 side, it might be as easy as turning the failing !this->IsDestroyed() check into an early return.

On the FileHandle side, it would be good to get a proper JS stack trace for the site of the assertion.

For a full-fledged example closer to a real-world application, visit https://github.com/budarin/http2-test-project

Socket.prototype._writeGeneric = function(writev, data, encoding, cb) {
// If we are still connecting, then buffer this for later.
// The Writable logic will buffer up any more writes while
// waiting for this one to be done.
if (this.connecting) {
this._pendingData = data;
this._pendingEncoding = encoding;
this.once('connect', function connect() {
this._writeGeneric(writev, data, encoding, cb);
});
"update" => recipes = update(args, path),
"install" => install(args, &recipes),
'use strict';
require('../common');
process.stdin.emit('end');
'use strict';
require('../common');
process.domain = null;
setTimeout(function() {
console.log('this console.log statement should not make node crash');
}, 1);