Skip to content

Instantly share code, notes, and snippets.

View fzn0x's full-sized avatar
🌎
Makes international software.

fzn0x fzn0x

🌎
Makes international software.
View GitHub Profile

Do not use forEach with async-await

TLDR: Use for...of instead of forEach in asynchronous code.

The problem

Array.prototype.forEach is not designed for asynchronous code. (It was not suitable for promises, and it is not suitable for async-await.)

For example, the following forEach loop might not do what it appears to do:

@fzn0x
fzn0x / OSX.md
Created February 25, 2022 05:59 — forked from r17x/OSX.md
MacOS common tools

Common Tools for development in Mac

xcode-select

  • version
xcode-select --version
// xcode-select version 2392.
  • Install
@fzn0x
fzn0x / fetchtransactionsbywallet.md
Last active January 6, 2022 17:31 — forked from shov/fetchtransactionsbywallet.md
Etherscan Public API Fetch By Contract or Wallet Address Tips

Etherscan Public API Fetch By Contract or Wallet Address Tips (edited by fncolon)

Overview

There is no documentation at the moment, but there are some rumors. And experimental way I've made sure about few end-points are working good:

Common account info

GET: https://www.etherchain.org/api/account/0xAAAsomeADDR00000000000/ Will return something like that:

{
@fzn0x
fzn0x / array_iteration_thoughts.md
Created December 16, 2021 09:30 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

Array Iteration

https://gist.github.com/ljharb/58faf1cfcb4e6808f74aae4ef7944cff

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it mu

<html>
<!-- You may need to download them from https://github.com/brix/crypto-js/tree/release-3.1.2/build -->
<script src="rollups/sha1.js"></script>
<script src='components/lib-typedarrays-min.js'></script>
<body>
<script>
function sha1sum() {
var oFile = document.getElementById('uploadFile').files[0];
var sha1 = CryptoJS.algo.SHA1.create();
var read = 0;
@fzn0x
fzn0x / GodDrinksJava.java
Created September 11, 2021 08:29 — forked from hibiyasleep/GodDrinksJava.java
world.execute(me);
package goddrinksjava;
/**
* The program GodDrinksJava implements an application that
* creates an empty simulated world with no meaning or purpose.
*
* @author momocashew
* @lyrics hibiyasleep
*/
@fzn0x
fzn0x / js-terms.md
Created March 17, 2021 11:49 — forked from r17x/js-terms.md
10 terms to help you better understand JavaScript

10 JavaScript Terms You Should Know

From currying to closures there are quite a number of special words used in JavaScript. These will not only help you increase your vocabulary but also better understand JavaScript. Special terms are normally found in documentation and technical articles. But some of them like closures are pretty standard things to know about. Knowing what the word itself means can help you know the concept it's named for better.

  1. Arity
  2. Anonymous
  3. Closure
  4. Currying
  5. Hoisting
  6. Mutation