Skip to content

Instantly share code, notes, and snippets.

View fzn0x's full-sized avatar
💻
Spot swing trader, blockchain enthusiast

Fauzan fzn0x

💻
Spot swing trader, blockchain enthusiast
View GitHub Profile
@fzn0x
fzn0x / antlr4.sh
Created February 22, 2022 20:30
ANTLR4
alias antlr4='java -jar /d/Projects/Javascript/antlr-javascript/antlr-4.9.3-complete.jar'
alias grun='java org.antlr.v4.runtime.misc.TestRig'
export CLASSPATH="/d/Projects/Javascript/antlr-javascript/antlr-4.9.3-complete.jar"
antlr4 Hello.g4
@fzn0x
fzn0x / aggregateDuplicateDataAndDeleteTheFirstData.js
Last active February 21, 2022 18:49
🍀 Simple mongoose script to be modified more to aggregate duplicate data with date range and delete the first data
import dotenv from "dotenv";
dotenv.config();
import mongoose from "mongoose";
import Axie from "./models/Axie.js";
const mongoSource = process.env.MONGO_SOURCE;
mongoose.connect(mongoSource, {});
const db = mongoose.connection;
@fzn0x
fzn0x / tip.cc
Created February 20, 2022 12:04
v8 console.log
void WriteToFile(const char* prefix, FILE* file, Isolate* isolate,
const debug::ConsoleCallArguments& args) {
if (prefix) fprintf(file, "%s: "⁠, prefix);
for (int i = 0; i < args.Length(); i++) {
HandleScope handle_scope(isolate);
if (i > 0) fprintf(file, " ");
Local arg = args[i];
Local str_obj;
@fzn0x
fzn0x / process_exit.any_lang
Created February 5, 2022 15:25
0 means false boolean but means clean for process.exit
exit(0) means a clean exit without any errors / problems
exit(1) means there was some issue / error / problem and that is why the program is exiting.
@fzn0x
fzn0x / promiseRaceAll.js
Created January 30, 2022 10:41
promiseRaceAll.js
Promise.delay = function (t, val) {
return new Promise((resolve) => {
setTimeout(resolve.bind(null, val), t);
});
};
Promise.raceAll = function (promises, timeoutTime, timeoutVal) {
return Promise.all(
promises.map((p) => {
return Promise.race([p, Promise.delay(timeoutTime, timeoutVal)]);
@fzn0x
fzn0x / TOOLS.md
Created January 24, 2022 02:31
Blockchain Concept Tools

Truffle

As you already did, you migrated a contract. So Truffle can be used for contract compilation and migration. It aims for easy and fast migration.

Geth

Is an Ethereum-client, which means that you can run your own private blockchain with it. You can adjust your needs by defining for example the amount of threads you offer for mining. Geth itself is a command line tool, which can run a full Ethereum node implemented in Go. It provides the command lines, a Json-rpc server and an interactive console, where you can run your own scripts written in javascript.

Ganache

If you want a GUI, where you can track all deployments and transactions on your blockchain, you can choose Ganache. It allows you to create your own private blockchain mainly for testing purposes. It is used for deployment-testing for example, because there are no real miners on a "ganache-blockchain", so you can test if your contracts work.

I would suggest you to use Geth and Truffle if you want to set up your own blockchain on your loc

@fzn0x
fzn0x / cool.md
Created January 20, 2022 08:20
Example of start fragment and end fragment tables styling
test runner testing framework
requires other libraries to work no preconfiguration required
offers a huge dose of flexibility regarding test development focused on simplicity
originally designed for Node.js originally designed for React
@fzn0x
fzn0x / index.html
Created January 17, 2022 06:34
Websocket client in browser isn't that hard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Client</title>
</head>
<body>
<!-- test purpose only -->
@fzn0x
fzn0x / shebang.md
Last active January 17, 2022 03:53
Shebang list, sh is not bash

Sh

  • #!/bin/sh
  • #!/bin/sh -

Bash

  • #!/usr/bin/env bash
  • #!/bin/bash

OpenBSD Bash

  • #!/usr/local/bin/bash
@fzn0x
fzn0x / validator.go
Created January 11, 2022 07:56
Validator logic domain
package domain
import (
"reflect"
"strings"
"github.com/go-playground/validator/v10"
)
func InitValidatorRules() *validator.Validate {