Skip to content

Instantly share code, notes, and snippets.

View JCMais's full-sized avatar
🚀
Being Happy

Jonathan Cardoso JCMais

🚀
Being Happy
View GitHub Profile
@sibelius
sibelius / learning-path-web3.md
Last active January 8, 2024 19:16
Learning Path Web3
  • learn blockchain concepts
  • learn ethereum
  • learn how to use metamask
  • learn how to use hardhat (https://hardhat.org/)
  • learn how to deploy and interact with a smart contract
  • learn common smart contract standards like ERC20 (token), ERC721 (nft), ERC1155 (opensea)
  • learn ipfs
  • learn how to read blockchain explorers like https://etherscan.io/
  • learn how to use web3 and etherjs
  • learn solidity
@sibelius
sibelius / useSWReg.tsx
Created May 26, 2020 11:57
use Service Worker Registration hook
import firebase from 'firebase/app';
import 'firebase/messaging';
import { useEffect, useRef } from 'react';
import config from '../config';
import firebaseConfig from './firebaseConfig';
import { PushTokenAddMutation } from './__generated__/PushTokenAddMutation.graphql';
import { PushTokenAdd, USER_PUSHENDPOINT_TYPE } from './PushTokenAddMutation';
@sibelius
sibelius / applyMiddleware.ts
Created April 7, 2020 11:55
trace resolver to generate span for each GraphQL resolver
import { addMiddleware } from 'graphql-add-middleware';
addMiddleware(schema, traceResolveMiddleware);
@JohnAlbin
JohnAlbin / _README.md
Last active March 18, 2024 09:25 — forked from clarkdave/createPages.ts
TypeScript + Gatsby config and node API

README

  1. When Gatsby starts up, it will read gatsby-config.js first.
  2. As you can see below, we use that file to require('ts-node').register() which registers a TypeScript evaluator that will be used when Gatsby reads all other API Javascript files. In other words, we only need to do this once in our entire codebase and not in other Gatsby files like gatsby-node.js.
  3. Our gatsby-config.js re-exports all the exported variables available in gatsby-config.ts.
@sibelius
sibelius / safeGoBack.tsx
Created July 19, 2019 15:21
Safe goBack helper to avoid leaving the site
export const safeGoBack = (
history: History,
alternativeRoute: string,
) => {
if (history.length > 2) {
history.goBack();
return;
}
history.push(alternativeRoute);
@lucianomlima
lucianomlima / adb_connect.sh
Created June 5, 2019 17:57
Connect to Android devices with ADB through wi-fi
function adb_connect {
# PORT used to connect. Default: 5555
PORT=${1:-5555}
# IP address from current device connected
IP_ADDRESS=`adb shell ip route | awk '{print $9}'`
echo "ADB connect to $IP_ADDRESS on port $PORT"
# Change connection from usb to tcpip using $PORT
@lucasbento
lucasbento / reload.sh
Created May 10, 2019 09:15
Reload react-native on Android from CLI
adb shell input keyevent 82 && adb shell input keyevent 19 && adb shell input keyevent 23
@sibelius
sibelius / Sample.tsx
Created February 27, 2019 15:47
useRelayPagination to be used with React Native Flatlist
const {
isFetchingEnd,
isFetchingTop,
onRefresh,
onEndReached,
} = useRelayPagination(relay, users);
const isRefreshing = isFetchingEnd || isFetchingTop;
<FlatList
@JCMais
JCMais / k8s-cluster.json
Created January 4, 2019 13:01
Grafana dashboards from kubernetes app but using prometheus metrics instead of the datasource from the plugin
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",

Deterministic save load in Factorio

One of the key parts of the save/load process in Factorio is that it must be deterministic. This means that for a given save file (when no external factors change) saving, exiting, and loading the save shouldn't change any observable behavior.

There are a few reasons and benefits for this strict requirement:

  • Without it: You couldn't join a running multiplayer game (and by proxy save, exit, and resume one)
  • Without it: the replay system wouldn't work if you ever saved, exited, and resumed playing.
  • With it: we can easily test that saving and loading produces no observable change letting us know we implemented save/load correctly.
  • With it: you won't see things change randomly as a result of "reloading" like you do in so many other games.