Skip to content

Instantly share code, notes, and snippets.

// 1. Import everything
import { Wallet, BigNumber, ethers, providers } from 'ethers'
const { FlashbotsBundleProvider, FlashbotsBundleResolution } = require('@flashbots/ethers-provider-bundle')
/*
Mainnet
const provider = new providers.JsonRpcProvider('https://eth-mainnet.g.alchemy.com/v2/cmHEQqWnoliAP0lgTieeUtwHi0KxEOlh')
const wsProvider = new providers.WebSocketProvider('wss://eth-mainnet.g.alchemy.com/v2/cmHEQqWnoliAP0lgTieeUtwHi0KxEOlh')
*/
import {
combineLatest,
distinctUntilChanged,
filter,
map,
Observable,
scan,
shareReplay,
switchMap,
withLatestFrom
@djsime1
djsime1 / fz_forks.md
Last active April 1, 2024 05:28
Flipper Zero firmware differences

This document has moved!

This comparison list has been relocated into the Awesome Flipper Zero repository. While you can read still read an archived version in this gist, all future updates will take place in the new repository.

Last archived version (Adapted from Nano's original messages in the Unleashed firmware Discord.)

Flipper Zero firmware differences

:: Last updated July 10 2022. ::

@jinschoi
jinschoi / create_sub.py
Last active February 24, 2024 06:53
Python script to generate Flipper RAW .sub files from OOK bitstreams
#!/usr/bin/env python3
from typing import Iterable, Union, Any
# freq: frequency in Hz
# zerolen: length of space bit in μs
# onelen: length of mark bit in μs
# repeats: number of times to repeat sequence
# pause: time to wait in μs between sequences
# bits: string of ones and zeros to represent sequence
@polster
polster / makefile
Created January 3, 2022 22:17
Kafka topics creation per make
#!make
KAFKA_BOOTSTRAP_SERVER=localhost:9092
KAFKA_TOPICS_FILE=./config/kafka/topics.txt
kafka-topics-create:
awk -F':' '{ system("kafka-topics.sh --create --bootstrap-server ${KAFKA_BOOTSTRAP_SERVER} --topic="$$1" --partitions="$$2" --replication-factor="$$3" --config="$$4) }' \
${KAFKA_TOPICS_FILE}
.PHONY: kafka-topics-create
@joawan
joawan / message_verification.js
Created September 14, 2021 20:04
Method to verify slack messages
const crypto = require('crypto');
const signSecret = process.env.SLACK_SIGN_SECRET;
const validateRequest = (requestSignature, requestTime, rawBody, validFor = 300) => {
const requestValidFrom = Math.floor(Date.now() / 1000) - validFor;
if (requestTime < requestValidFrom) {
throw new Error(`Request outdated: !(${requestTime} < ${requestValidFrom})`);
}
@thaaddeus
thaaddeus / liquidations_monitor.ts
Last active June 5, 2023 12:18
Liquidations monitor
import { streamNormalized, normalizeLiquidations, combine, Liquidation } from 'tardis-dev'
// let's monitor BTC perpetuals swaps only
const monitoredExchanges = [
{ id: 'ftx', symbols: ['BTC-PERP'] },
{ id: 'bitmex', symbols: ['XBTUSD'] },
{ id: 'deribit', symbols: ['BTC-PERPETUAL'] },
{ id: 'binance-futures', symbols: ['BTCUSDT'] },
{ id: 'binance-delivery', symbols: ['BTCUSD_PERP'] },
{ id: 'bitfinex-derivatives', symbols: ['BTCF0:USTF0'] },
function partition(inputArray, callback) {
const result = {};
for (const [indexOfValue, value] of inputArray.entries()) {
const propertyKey = callback(value, indexOfValue);
if (propertyKey === null || propertyKey === '') {
continue;
}
if (!{}.hasOwnProperty.call(result, propertyKey)) {
result[propertyKey] = [];
}
@kyleshevlin
kyleshevlin / signupMachine.js
Created May 20, 2020 20:43
a state chart for a signup form
const submitEvent = {
SUBMIT: [
{
target: 'submitting',
cond: 'isValidData',
},
{ target: 'error' },
],
}
const designerSubChart = {
initial: 'standard',
states: {
standard: {
on: {
'': {
target: 'readOnly',
cond: 'hasReadOnlyParam'
},
ENTER_PREVIEW: 'preview',