Skip to content

Instantly share code, notes, and snippets.

View dangdennis's full-sized avatar

Dennis Dang dangdennis

View GitHub Profile
@miguelmota
miguelmota / KmsSigner.js
Last active January 11, 2023 15:26
JavaScript ethers Signer using AWS KMS
const { BigNumber, Signer } = require('ethers')
const { keccak256, recoverAddress, joinSignature, resolveProperties, serializeTransaction, hashMessage, arrayify, defineReadOnly } = require('ethers/lib/utils')
const { KMSClient, GetPublicKeyCommand, SignCommand } = require('@aws-sdk/client-kms')
const asn1 = require('asn1.js')
const EcdsaPubKey = asn1.define('EcdsaPubKey', function () {
this.seq().obj(
this.key('algo').seq().obj(
this.key('a').objid(),
this.key('b').objid()
@krpeacock
krpeacock / create_canister.rs
Created August 20, 2021 18:31
Create canister from dfx
use crate::lib::environment::Environment;
use crate::lib::error::DfxResult;
use crate::lib::ic_attributes::CanisterSettings;
use crate::lib::identity::identity_utils::CallSender;
use crate::lib::identity::Identity;
use crate::lib::models::canister_id_store::CanisterIdStore;
use crate::lib::provider::get_network_context;
use crate::lib::waiter::waiter_with_timeout;
use anyhow::anyhow;
@kentcdodds
kentcdodds / cachified.ts
Last active April 19, 2023 04:54
Turn any function into a cachified one. With forceFresh support and value checking (for when the data type changes). This uses redis, but you could change it to use whatever you want.
type CacheMetadata = {
createdTime: number
maxAge: number | null
expires: number | null
}
function shouldRefresh(metadata: CacheMetadata) {
if (metadata.maxAge) {
return Date.now() > metadata.createdTime + metadata.maxAge
}
@mcansh
mcansh / !RemixVercelGitHubAction.markdown
Last active February 27, 2024 14:34
GitHub Action for automatically deploying a Remix app to Vercel

Things to note to make this work:

  1. you'll need to have your remix registry token available in your shell under REMIX_TOKEN
  2. you'll need to add secrets to your GitHub repo for the following items:
  3. you'll need to have your REMIX_TOKEN available in your vercel repo as an environment variable
@tranquan
tranquan / xcode-keybindings-as-vscode.md
Last active July 1, 2024 18:09
Xcode KeyBindings as VSCode
@graninas
graninas / What_killed_Haskell_could_kill_Rust.md
Last active June 22, 2024 07:05
What killed Haskell, could kill Rust, too

At the beginning of 2030, I found this essay in my archives. From what I know today, I think it was very insightful at the moment of writing. And I feel it should be published because it can teach us, Rust developers, how to prevent that sad story from happening again.


What killed Haskell, could kill Rust, too

What killed Haskell, could kill Rust, too. Why would I even mention Haskell in this context? Well, Haskell and Rust are deeply related. Not because Rust is Haskell without HKTs. (Some of you know what that means, and the rest of you will wonder for a very long time). Much of the style of Rust is similar in many ways to the style of Haskell. In some sense Rust is a reincarnation of Haskell, with a little bit of C-ish like syntax, a very small amount.

Is Haskell dead?

Introduction

  1. What's new with the Metamask plugin
  • Permission System :- users are forced to consent to some truly excessive permissions
  • Plugin System :- important innovations are happening all around us, from scaling strategies, to new smart contract protocols, and many of these require interacting with a user’s accounts, and running a persistent script
  1. How this improves the extension
@davidgilbertson
davidgilbertson / http2.js
Last active October 9, 2023 06:09
HTTP2 server with compression and caching
const http2 = require('http2');
const fs = require('fs');
const path = require('path');
const zlib = require('zlib');
const brotli = require('brotli'); // npm package
const PORT = 3032;
const BROTLI_QUALITY = 11; // slow, but we're caching so who cares
const STATIC_DIRECTORY = path.resolve(__dirname, '../dist/');
const cache = {};
@dyaa
dyaa / firebase.js
Last active February 10, 2024 08:58
Lazy Load Import Firebase (dynamic import)
Promise.all([
import('firebase/app'),
import('firebase/database'),
import('firebase/auth'),
])
.then(x => x[0].default)
.then(firebase => {
const config = {
apiKey: '',
authDomain: '',
@gaearon
gaearon / prepack-gentle-intro-1.md
Last active May 3, 2024 12:56
A Gentle Introduction to Prepack, Part 1

Note:

When this guide is more complete, the plan is to move it into Prepack documentation.
For now I put it out as a gist to gather initial feedback.

A Gentle Introduction to Prepack (Part 1)

If you're building JavaScript apps, you might already be familiar with some tools that compile JavaScript code to equivalent JavaScript code:

  • Babel lets you use newer JavaScript language features, and outputs equivalent code that targets older JavaScript engines.