Skip to content

Instantly share code, notes, and snippets.

@imthenachoman
imthenachoman / Developing a GAS Powered Google Workspace Add-on And Launching It To The Marketplace.md
Last active June 24, 2024 15:49
Developing a GAS Powered Google Workspace Add-on And Launching It To The Marketplace
@teddav
teddav / AngleExplainsYul.sol
Last active March 17, 2023 14:53
Tutorial for writing a basic contract in Yul (assembly). See https://blog.angle.money/playing-with-yul-cd4785e456d8
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.15;
contract AngleExplains {
uint private secretNumber;
mapping(address => uint) public guesses;
bytes32 public secretWord;
@grGred
grGred / GasOptimizations.md
Last active July 12, 2024 08:56
Solidity gas optimizations and tricks

Upgrade pragma to latest Solidity compiler version


Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For example, OpenZeppelin libraries typically have a lot of small helper functions and if they are not inlined, they cost an additional 20 to 40 gas because of 2 extra jump instructions and additional stack operations needed for function calls.
  • Optimizer improvements in packed structs: Before 0.8.3, storing packed structs, in some cases used an additional storage read operation. After [EIP-
@hrkrshnn
hrkrshnn / generic.org
Last active April 21, 2024 01:51
Some generic writeup about common gas optimizations, etc.

Upgrade to at least 0.8.4

Using newer compiler versions and the optimizer gives gas optimizations and additional safety checks for free!

The advantages of versions 0.8.* over <0.8.0 are:

  • Safemath by default from 0.8.0 (can be more gas efficient than some library based safemath).
  • Low level inliner from 0.8.2, leads to cheaper runtime gas. Especially relevant when the contract has small functions. For
@shanerbaner82
shanerbaner82 / MintFunction
Created August 31, 2021 17:36
Mint w Gas
async mint(context, amount) {
const mintValue = web3.utils.toWei((amount * context.state.contractData.nftPrice).toString(), 'ether');
const contract = new web3.eth.Contract(ABI, process.env.CONTRACT_ADDRESS);
try {
const value = web3.utils.toHex(mintValue);
const data = contract.methods.mintFunction(amount).encodeABI();
const transactionParameters = {
@mayrsascha
mayrsascha / UrlFetchAppWithRetries.gs
Last active February 24, 2022 22:00 — forked from Bajena/RetriableRequestsBatch.gs
Retriable requests batch for Google Apps Scripts. Originally seen on https://medium.com/@sidehacker/nice-did-you-consider-making-this-a-gas-library-dee19ce3db4a. Install it by adding the library script ID "16rm4lelUzHsrF_vLJOwYFh6HvnZHM5LhT8zOn45YvdeQdsZVZmlIOhDP".
/**
* --- UrlFetchApp WITH retries ---
*
* Don't let your script fail easily because of bad API uptime.
*
* Calls provided HTTP requests batch and retries in case of errors. This function has the same
* params and return value as URLFetchApp.fetchAll().
* https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetchurl-params
*
* @param {Array<object>} requests - Array of request param objects
@lucashmsilva
lucashmsilva / TESOURODIRETO(taxa).js
Last active January 11, 2024 13:26
API para criar a função TESOURODIRETO Google Sheets
/*
* @return Retorna a cotação atual de um título específico do Tesouro Direto Junto com a taxa anual de retorno
* @customfunction
**/
function TESOURODIRETO(bondName) {
let srcURL = "https://www.tesourodireto.com.br/json/br/com/b3/tesourodireto/service/api/treasurybondsinfo.json";
let jsonData = UrlFetchApp.fetch(srcURL);
let parsedData = JSON.parse(jsonData.getContentText()).response;
for(let bond of parsedData.TrsrBdTradgList) {
@natanlao
natanlao / github-global-node-id.md
Last active June 29, 2024 04:31
Translating GitHub resource IDs to global node IDs

GitHub associates a unique resource ID (or "database ID" or just "ID") with each API-accessible resource. For example, each [issue][issue-id], [repository][repository-id], and [user][user-id] has a global ID. In my limited experience with it, GitHub's REST API generally does not expose endpoints by which resources can be queried by ID (though it does have some [undocumented endpoints][repo-rest]). These resource IDs have been superseded by distinct [global node IDs][global-ids] (node_id). GitHub's GraphQL API allows retrieval of a node by its ID, called a "direct node lookup".

As you can tell, you likely don't have much reason to interact with the older

import numpy as np
import casadi
from casadi import SX, DM
from math import cos, sin
import cv2
# State Vector Indices
index_mass = 0
index_position_x = 1
index_position_y = 2
@Foadsf
Foadsf / .gitignore
Last active February 12, 2022 00:00
Scilab Serial Communication Toolbox (SSCT) --> this Gist is deprecated. please use https://github.com/Foadsf/ssct
docinfo.html
Documentation.md
pics/