Skip to content

Instantly share code, notes, and snippets.

View ravidsrk's full-sized avatar
🎯
Focusing

Ravindra Kumar ravidsrk

🎯
Focusing
View GitHub Profile
const _ = require("lodash");
const BnbApiClient = require("@binance-chain/javascript-sdk");
const kava = require("@kava-labs/javascript-sdk");
const bnbCrypto = BnbApiClient.crypto;
const KavaClient = kava.KavaClient;
const kavaUtils = kava.utils;
const BINANCE_CHAIN_API_TESTNET = "https://testnet-dex.binance.org";
const BINANCE_CHAIN_DEPUTY = "tbnb1et8vmd0dgvswjnyaf73ez8ye0jehc8a7t7fljv";
const bnbAddress = "your binance chain testnet address";
@ravidsrk
ravidsrk / prettier.sh
Created April 14, 2019 19:52 — forked from whoisryosuke/prettier.sh
Prettier - Format or unminify code (single file or any folder of certain files)
# Quickly fix one file
npx prettier --write your-file.html
# Quickly fix all files of one type
npx prettier --write src/**/*.{js,jsx}
@ravidsrk
ravidsrk / Knex-Migrations-Seeding.md
Created March 27, 2019 15:29 — forked from NigelEarle/Knex-Migrations-Seeding.md
Migration and seeding instructions using Knex.js!

Migrations & Seeding

What are migrations??

Migrations are a way to make database changes or updates, like creating or dropping tables, as well as updating a table with new columns with constraints via generated scripts. We can build these scripts via the command line using knex command line tool.

To learn more about migrations, check out this article on the different types of database migrations!

Creating/Dropping Tables

@ravidsrk
ravidsrk / pget.go
Created March 18, 2019 07:39 — forked from montanaflynn/pget.go
Bounded Parallel Get Requests in Golang
package main
import (
"fmt"
"net/http"
"sort"
"time"
)
// a struct to hold the result from each request including an index
export const contracts = {
"0x1d462414fe14cf489c7a21cac78509f4bf8cd7c0": {
id: "canyacoin"
},
"0x5f3789907b35dce5605b00c0be0a7ecdbfa8a841": {
id: "content-and-ad-network",
},
"0xdd974d5c2e2928dea5f71b9825b8b646686bd200": {
id: "kyber-network"
},
@ravidsrk
ravidsrk / setup.sh
Created December 29, 2018 07:43
Parity Node Setup
sudo apt-get install openssl libssl-dev libudev-dev
sudo apt-get install software-properties-common -y
sudo add-apt-repository -y ppa:ethereum/ethereum -y
sudo apt-get update
sudo apt-get install ethereum
bash <(curl https://get.parity.io -L)
parity — cache-size 62000 — warp — jsonrpc-interface "206.189.140.131" — jsonrpc-apis "all" — ipc-apis "web3,eth,personal,pubsub,net,parity,parity_pubsub,parity_accounts,traces,rpc,secretstore" — jsonrpc-port "8545" — mode "active" — chain "mainnet" — min-peers 50 — max-peers 200
@ravidsrk
ravidsrk / random.md
Created November 28, 2018 08:35 — forked from joepie91/random.md
Secure random values (in Node.js)

Not all random values are created equal - for security-related code, you need a specific kind of random value.

A summary of this article, if you don't want to read the entire thing:

  • Don't use Math.random(). There are extremely few cases where Math.random() is the right answer. Don't use it, unless you've read this entire article, and determined that it's necessary for your case.
  • Don't use crypto.getRandomBytes directly. While it's a CSPRNG, it's easy to bias the result when 'transforming' it, such that the output becomes more predictable.
  • If you want to generate random tokens or API keys: Use uuid, specifically the uuid.v4() method. Avoid node-uuid - it's not the same package, and doesn't produce reliably secure random values.
  • If you want to generate random numbers in a range: Use random-number-csprng.

You should seriously consider reading the entire article, though - it's

Principles of Adult Behavior

  1. Be patient. No matter what.
  2. Don’t badmouth: Assign responsibility, not blame. Say nothing of another you wouldn’t say to him.
  3. Never assume the motives of others are, to them, less noble than yours are to you.
  4. Expand your sense of the possible.
  5. Don’t trouble yourself with matters you truly cannot change.
  6. Expect no more of anyone than you can deliver yourself.
  7. Tolerate ambiguity.
  8. Laugh at yourself frequently.
@ravidsrk
ravidsrk / express-server-side-rendering.md
Created August 7, 2018 10:25 — forked from joepie91/express-server-side-rendering.md
Rendering pages server-side with Express (and Pug)

Terminology

  • View: Also called a "template", a file that contains markup (like HTML) and optionally additional instructions on how to generate snippets of HTML, such as text interpolation, loops, conditionals, includes, and so on.
  • View engine: Also called a "template library" or "templater", ie. a library that implements view functionality, and potentially also a custom language for specifying it (like Pug does).
  • HTML templater: A template library that's designed specifically for generating HTML. It understands document structure and thus can provide useful advanced tools like mixins, as well as more secure output escaping (since it can determine the right escaping approach from the context in which a value is used), but it also means that the templater is not useful for anything other than HTML.
  • String-based templater: A template library that implements templating logic, but that has no understanding of the content it is generating - it simply concatenates together strings, potenti
@ravidsrk
ravidsrk / createContract.js
Created July 29, 2018 18:45 — forked from frozeman/createContract.js
Deploy contracts on Ethereum and reliable get the contract address
// -> Soldity
// **********
// Your Soldity contract
event Created(bytes32 indexed identifier);
contract MyContract {
function MyContract(bytes32 identifier) {
Created(identifier);
}