Skip to content

Instantly share code, notes, and snippets.

View onggunhao's full-sized avatar

Daniel Ong onggunhao

View GitHub Profile
@onggunhao
onggunhao / keybase.md
Created November 16, 2019 21:17
keybase.md

Keybase proof

I hereby claim:

  • I am onggunhao on github.
  • I am onggunhao (https://keybase.io/onggunhao) on keybase.
  • I have a public key ASCSN_pRgiwnlu7PH7kTkGo_E5pDmOOx1owPAmzL6zEfBwo

To claim this, I am signing this object:

@onggunhao
onggunhao / solidity-invalid-params.md
Last active July 21, 2019 19:11
Invalid number of parameters for function in Solidity

Possibility 1: Build is outdated Need to recompile all Truffle contracts

Overloaded function

Truffle Release Notes

'Invalid number of parameters for "withdraw". Got 2 expected 0!'

Need to use syntax:

@onggunhao
onggunhao / solhint-with-prettier.json
Created July 5, 2019 10:20
Solhint.json with Prettier-Solidity
{
"extends": ["solhint:recommended"],
"rules": {
"prettier/prettier": "error",
"avoid-throw": false,
"avoid-suicide": "error",
"avoid-sha3": "warn"
},
"plugins": ["prettier"]
}
@onggunhao
onggunhao / basic-solhint.json
Last active July 5, 2019 10:20
Basic Solhint-only setup with recommended rules
{
"extends": "solhint:recommended",
"plugins": [],
"rules": {
"avoid-throw": false,
"avoid-suicide": "error",
"avoid-sha3": "warn"
}
}
@onggunhao
onggunhao / pmt-solidity.sol
Last active June 30, 2019 14:37
A prototype implementation of excel's PMT function in Solidity, using the ABDKMath library for 64 bit fixed numbers. Verified to work with principal amounts with 18 decimals (e.g. Dai contract)
pragma solidity ^0.5.7;
contract PMT {
using ABDKMath64x64 for uint128;
// rate is in basis points (0.5% = 50)
function pmt(int128 rate, uint256 numPayments, int128 principal)
public
returns (int128)
{

Overview of the Ethereum Dataset

Hi Sourav,

This is knowledge transfer of lessons I learnt working with Ethereum. I had to figure out a lot of this from scratch, so hopefully this saves you a lot of time.

The current geth node on andromeda is in a local environment so passwords etc will be included in this write-up (see the last page), but please change them as soon as possible for hygiene purposes.

Conceptual overview of dataset

@onggunhao
onggunhao / fix-x11-connection-rejected.md
Last active January 5, 2023 08:27
Fixing "X11 connection rejected because of wrong authentication" when running gnome-terminal

Fixing X11 connection rejected errors

This is written for newcomers to the lab, who often experience X11 connection rejected errors when running gnome-terminal (you need this to run atom, sublime text etc to edit on a remote server).

For more info, read the full answer on StackExchange https://unix.stackexchange.com/questions/412065/ssh-connection-x11-connection-rejected-because-of-wrong-authentication

1. Log onto remote server (Andromeda)

echo $DISPLAY This should display your current X11 display

xauth list If nothing prints on console, it means ssh did not automatically generate the X11 authorization cookies on the local display properly

049d770fc7924b6b3a23da1a17a6e3fa970e12a6611d719c81bb5460ba5319963697a4886e81e5c527eb243b6672024470e8766cdae4eb7fade5d513b364a774d3

Deploying Bitcoin-VR on Github Pages

Before

  1. Read Facebook's React VR deployment guide.
  2. Copy the list of static assets files in reactvrinit.js. (TODO: write automated script to handle this)
ReactVR.init(
  // When you're ready to deploy your app, update this line to point to
  // your compiled index.bundle.js
 './index.bundle.js?platform=vr',
@onggunhao
onggunhao / blockchain-websocket-api.md
Last active August 9, 2023 20:26
Annotated version of Blockchain.info's Websocket Transaction

Annotated Blockchain.info Websocket API

This is an annotated version of Blockchain.info's Websocket API with explanations of message contents.

Multiple Inputs and Outputs

Bitcoin transactions (especially if large) may have multiple inputs and outputs in a single transaction. http://chimera.labs.oreilly.com/books/1234000001802/ch02.html explains this very concisely.

Sample Transaction

The JSON object below is the actual message received from the Blockchain.info Websockets API for the transaction 0857b9de1884eec314ecf67c040a2657b8e083e1f95e31d0b5ba3d328841fc7f. You can see the Blockchain.info transaction page for this transaction here.

Transaction Page: