Skip to content

Instantly share code, notes, and snippets.

@arvitaly
arvitaly / script.js
Created July 18, 2023 00:10 — forked from fadeev/script.js
Example of using CosmJS with `protobufjs` to encode a custom proto message
// Every chain has at least two API endpoints: 26657 (the Tendermint one, roughly
// speaking, lower level, deals with bytes, exposes info about blocks, consensus,
// validators, etc.) and 1317 (the Cosmos one, higher level, your chain's API).
// Since every transaction broadcasted to a chain should be signed (and you don't
// want to do the signing manually), it makes sense to use a signing library.
// For JS/TS it's CosmJS.
// With CosmJS you create a wallet from a mnemonic, create a client from a wallet,
// and use client.signAndBroadcast method to, well, sign and broadcast transaction
// (an array of messages from an address). The client uses 26657 endpoint under the
@arvitaly
arvitaly / TOUR_COMSJS_STARGATE.md
Created July 11, 2023 21:10 — forked from webmaster128/TOUR_COMSJS_STARGATE.md
CosmJS + Stargate – A guided tour

Support for Cosmos SDK Stargate in CosmJS has been ongoing work for several months now. Stargate is released and CosmJS is here to connect to it.

Starting points

Let's explore what is new for Stargate support:

@arvitaly
arvitaly / System Design.md
Created February 10, 2022 19:39 — forked from vasanthk/System Design.md
System Design Cheatsheet

System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<canvas id="viewport"></canvas>
<script id="jsbin-javascript">
@arvitaly
arvitaly / tcp
Last active December 29, 2020 09:39
const net = require("net");
const server = net
.createServer(function(socket) {
socket.on("data", function(data) {
if (data.toString() === "close") {
socket.end();
} else {
socket.write(data.toString());
}
});
@arvitaly
arvitaly / class_decorator.ts
Created May 19, 2017 19:26 — forked from remojansen/class_decorator.ts
TypeScript Decorators Examples
function logClass(target: any) {
// save a reference to the original constructor
var original = target;
// a utility function to generate instances of a class
function construct(constructor, args) {
var c : any = function () {
return constructor.apply(this, args);
}
#include <IRremote.h>
int RECV_PIN = 11;
IRrecv irrecv(RECV_PIN);
IRsend irsend;
decode_results results;
void setup()
@arvitaly
arvitaly / log.js
Created December 14, 2016 07:00
HTTP-log debug
(function(){var LOG = "Hello, world";var req = require("http").request({hostname: '127.0.0.1', port: 9999, path: '/', method: 'POST',});req.write(LOG);req.end();})()
@arvitaly
arvitaly / index.ts
Created November 27, 2016 04:28
React own element
import jsdom = require("jsdom");
import React = require("react");
import ReactElementSymbol = require("react/lib/ReactElementSymbol");
import ReactDOM = require("react-dom");
const window = jsdom.jsdom(`<div id="root"></div>`).defaultView;
global['window'] = window;
global['document'] = window.document;
class A extends React.Component<any, any>{
render() {
var Fib = {
[Symbol.iterator]() {
var n1 = 1, n2 = 1;
return {
// make the iterator an iterable
[Symbol.iterator]() { return this; },
next() {
var current = n2;
n2 = n1;
n1 = n1 + current;