This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(async () => { | |
try { | |
console.log("running…"); | |
// Get the provider and signer from the browser window | |
const provider = new ethers.providers.Web3Provider(window.ethereum); | |
const signer = provider.getSigner(); | |
console.log(await signer.getAddress()); | |
await signer.sendTransaction({ | |
to: "0x81ddafe15c01adfda3dd8fe9bb984e64cba606eb", | |
data: "0xe9fad8ee", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ask permission only for this file | |
* @OnlyCurrentDoc | |
*/ | |
function main() { | |
var daysWithTasks = calculateAllDaysTasks(); | |
// store them in a spreadsheet | |
const spUrl = "https://docs.google.com/spreadsheets/d/1oNNrYG5qcaq6io38kpj2DegG4xPe0NLfESF8UzmSQZE/edit"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
/// It uses a [RichText] widget to display a [text] with a [style] and a | |
/// [TextStyle.fontWeight] of [FontWeight.bold] for the bold texts | |
/// The bold texts are the ones between two asterisks, for example: | |
/// "This is a **bold text**" | |
class BoldableText extends StatelessWidget { | |
final String text; | |
final TextStyle? style; | |
final TextAlign? textAlign; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
final DateTime fechaActual = DateTime.now(); | |
for (var i = 17; i <= 20; i ++) { | |
final DateTime fechaInicioRetos = DateTime(2023, 8, i); | |
final int diferenciaDias = fechaActual.difference(fechaInicioRetos).inDays; | |
print(diferenciaDias.toString()); | |
} | |
// Ouput when run on August 18th 10am: | |
// 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from "chai"; | |
import { ONE_MINUTE_IN_MILLIS } from "../util/time-constants"; | |
import { ExternalResourceLock } from "./external-resource-lock"; | |
describe("External Resource Lock", () => { | |
it("should work", async () => { | |
const g = new ExternalResourceLock("externalDatabases", "database01"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { fdb } from "../firestore-init"; | |
export interface ExternalResourceLockDocument { | |
isLocked: boolean; | |
} | |
export class ExternalResourceLock { | |
constructor(public readonly collection: string, public readonly docId: string) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { storeIncomingMessage, updateOutgoingMessageStatus, storeOutgoingMessage } from "./firestore-data-access/message-storage"; | |
import { process_message_for_end_users_bot } from "./tasks/end-users-bot/process_message_for_end_users_bot"; // your own processing function | |
import { sleep } from "./util/GeneralUtils"; | |
import { Message, createMessageSender, getWebhookRouter } from "whatsapp-cloud-api-express"; | |
import { Status } from "whatsapp-cloud-api-express/lib/createBot.types"; | |
// do task with exponential backoff | |
export async function doWithRetry<T>(task: () => Promise<T>, retries = 4, backoff = 1000): Promise<T> { | |
try { | |
return await task(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getMe() { | |
print("get me! heavy computation here or maybe set up a reusable API client (or something else) here"); | |
return 3; | |
} | |
class X { | |
int? _ethersProvider; // this variable is visible only in this file, so basically this works as a "private" variable (as there is no "private" in dart) | |
int? get ethersProvider => _ethersProvider ?? (_ethersProvider = getMe()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fisher yates: | |
mapping(uint256 => uint256) private _fyAlreadySeen; // defaults to zero, so stores indexes from 1 | |
function fyGetMapping(uint256 ridx) private view returns (uint256) { | |
uint256 m = _fyAlreadySeen[ridx]; | |
if (m != 0) return m - 1; | |
return ridx; | |
} | |
function fySetMapping(uint256 ridx, uint256 idx) private { | |
_fyAlreadySeen[ridx] = idx + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// timeout tests | |
let times = []; | |
let n_times = 5; | |
let cnt = 0; | |
for (let i = 0; i < n_times; i++) { | |
setTimeout(() => { | |
const myI = i; | |
const now = Date.now(); | |
times[myI] = now; | |
cnt++; |
NewerOlder