Skip to content

Instantly share code, notes, and snippets.

View learner-long-life's full-sized avatar

Paul Pham learner-long-life

View GitHub Profile
public void updateJarFile(File srcJarFile, String targetPackage, File ...filesToAdd) throws IOException {
File tmpJarFile = File.createTempFile("tempJar", ".tmp");
JarFile jarFile = new JarFile(srcJarFile);
boolean jarUpdated = false;
try {
JarOutputStream tempJarOutputStream = new JarOutputStream(new FileOutputStream(tmpJarFile));
try {
//Added the new files to the jar.
As for running your own Ethereum node, that's what you might want to do if you are going to be
making many smart contract calls for your users. Most people use Infura's free public nodes for
casual calls or development, but when they have a production system, they have to pay per 1000
smart contract calls or they can run their own dedicated Ethereum nodes. This involves maintaining
a Linux system and syncing the blockchain, and people who do this often use Amazon's hosted service, AWS.
I suspect Infura also uses AWS.
So for the same AWS credits, you could run a subgraph / GraphQL server to index the Ethereum events,
and have your front-end query it much more efficiently each time a user refreshes your website, instead
of calling the Ethereum mapping getter method repeatedly. You'll probably want to run your own subgraph server,
@learner-long-life
learner-long-life / EthereumDev.md
Created July 31, 2017 02:18
How to Set up an Ethereum Dev Environment

How to Set up an Ethereum Dev Environment

So you want to be an Ethereum developer! Congrats, much treasure awaits you. Developing Ethereum dapps benefits from having a well-crafted development environment. This can often be daunting to beginners, so I'm giving you my favorite dev environment to help get you started.

Once your code fortress is constructed, you'll be able to

  • Compile smart contracts written in Solidity
@learner-long-life
learner-long-life / EthereumNodeGCP.md
Last active October 4, 2022 11:54
How to Run an Ethereum (Geth Light) Node on GCP

How to Run an Ethereum Node in GCP

NOTE: This doc was created in 2018 and is no longer being kept up-to-date. There are some useful updates and Q&A in the comments, and Google has since disallowed cryptocurrency nodes explicitly in their Terms of Service. While I work on an updated how-to-run-a-node tutorial, you are welcome to join our ETH developer chat and share what you'd like to work on.

https://matrix.to/#/#invisible-college/cryptocoin:matrix.org?via=matrix.org&via=t2bot.io

@learner-long-life
learner-long-life / Rinkeby.md
Last active August 30, 2022 22:32
How to get on Rinkeby Testnet in less than 10 minutes

How to get on Rinkeby Testnet in less than 10 minutes

Following instructions from the excellent https://www.rinkeby.io/

Synchronizing a Full Node

A full node lets you access all state. There is a light node (state-on-demand) and wallet-only (no state) instructions as well,

0xb2e9fe08ca9a0323103883fe12c9609ed380f475
@learner-long-life
learner-long-life / gist:ea796ad989c351a9d2df3f455d5334e3
Last active January 14, 2022 21:49
A response to Moxie's web3 critique
In response to https://moxie.org/2022/01/07/web3-first-impressions.html
A well-stated critique is worth its weight in gold. I'm a fan of the work on encrypted text messenging by
anyone named Moxie Marlinspike, and acknowledge that it reflects a particular ethos, exhibited by Signal,
a project that Moxie co-founded with Brian Acton. This ethos is strongly opinionated on behalf of users,
makes the best choice for most people in a large variety of cryptographic
protocols and their parameters, and offers it in a tightly integrated desktop/mobile app and centralized
server infrastructure.
Marlinspike raises a valid gap between the decentralized ethos of web3, and a few centralized providers of its data.
@learner-long-life
learner-long-life / gist:cbe3c12eafc1d57e2201980ee6a2946c
Created January 12, 2022 02:46
Proposed Decentralized Cloud Server
Let's say you have a serverless cloud function system which reproducible, stateless, only operates on its immutable inputs and produces immutable output all the functional things.
```
F(x) = y
```
You also have an on-chain verifier function (I know, unrealistic, but we'll try and fix this later) that you can run, much faster than `F`, that you publish on a ledger tied to
```
G(x,y) = true for all x, y=F(x)
false otherwise with overwhelming probability
```
@learner-long-life
learner-long-life / DecentWebWallets.md
Last active May 26, 2021 23:21
Ethereum / Decentralized Web Wallets, Desiderata and Tradeoffs

Decentralized Web Wallets

After reading about current options for secure browser storage for wallets, https://www.rdegges.com/2018/please-stop-using-local-storage/

I think I understand the tradeoffs of the different approaches, which is helping me write my own web wallet (called Democracy), currently for Ethereum.

I'd like to check my understanding here. Any feedback appreciated below in comments.

@learner-long-life
learner-long-life / First Step
Last active April 11, 2021 12:25
Google Foobar Problem - Peculiar Balance
The Peculiar Balance is a device which contains a weight, of value n units, and gives you an infinite set of fixed weights
with values 1, 3, 9, 27, ... and so forth, all powers of three.
The known weight n is on the left side of the balance, and there is a right side (initially empty).
Your goal is to balance the Peculiar Balance, with a weight that you know (n), using only the fixed weights,
placed either on the right or the left side.
As a first step, given n, come up with a formula for M, the smallest fixed weight which, when placed on the
right-hand side, would tip the balance to the right (i.e. the smallest fixed weight that is still greater than n).