Skip to content

Instantly share code, notes, and snippets.

View gre's full-sized avatar
3 cups required

@greweb gre

3 cups required
View GitHub Profile
@gre
gre / package.json
Last active December 13, 2019 19:37
live-common in a nutshell
{
"private": true,
"name": "send-example",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@ledgerhq/hw-transport-node-hid-noevents": "canary",
"@ledgerhq/ledger-core": "alpha",
"@ledgerhq/live-common": "alpha",
require("babel-polyfill");
const request = require("request");
const { listTokens } = require("@ledgerhq/live-common/lib/currencies");
require("@ledgerhq/live-common/lib/load/tokens/ethereum/erc20");
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const fetch = url =>
new Promise((resolve, reject) =>
request(url, (error, response, body) => {
/*
* I want to trigger something 5s after mount with some props
*/
const Thing = ({ a, b }) => {
useEffect(() => {
const timeout = setTimeout(() => {
doTheThing(a, b);
}, 5000);
async function suspenseReadToPromise(read, ...args) {
let value;
try {
value = read(...args);
} catch (e) {
if (e && typeof e.then === "function") {
value = await e;
}
else {

Keybase proof

I hereby claim:

  • I am gre on github.
  • I am greweb (https://keybase.io/greweb) on keybase.
  • I have a public key whose fingerprint is 70D1 29E9 37F5 DB8B BC04 6E46 92B0 2128 CF8C 915B

To claim this, I am signing this object:

class Finish extends r.Component {
constructor(...e) {
var t
return (
(t = super(...e)),
Object.defineProperty(this, 'state', {
configurable: !0,
enumerable: !0,
writable: !0,
value: { emit: !1 },
@gre
gre / ethereum_ledger_integration.md
Last active March 8, 2022 05:41
Quick Guide for Ethereum Ledger Integration

How to integrate the Ledger device with a Ethereum Web Application

This is a quick guide to show how to integrate Ledger Ethereum libraries into an existing web application.

If you are starting a new DApp project from scratch, or simply are beginning in this Ethereum Smart Contract world, we have made create-dapp Starter Kit for you, it comes with a out-of-the-box support of Ledger and MetaMask and shows a complete smart contract example (that allows to get/set a value globally).

Whether you want to integrate on an existing app or bootstrap it from scratch with our starter kit, the follow guide will drive you to important part on how things work with the Ledger.

Prerequisites of the guide

function recordHistory() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
// Toggle a cell that is used in one of a CRYPTOFINANCE formula to force-trigger a refresh
var r = ss.getSheetByName("folio").getRange("A30");
var unit = r.getValues()[0][0];
r.setValue(unit==='BTCEUR'?'BTC/EUR':'BTCEUR');
// accumulate history
var sheet = ss.getSheetByName("History");
import React, { Component } from "react";
class Counter extends Component {
state = { count: 1 };
onClick = () => this.setState(({ count }) => ({ count: count + 1 }));
render() {
return (
<button onClick={this.onClick}>
{this.state.count}
</button>
@gre
gre / AspectRatioDiv.js
Created March 10, 2017 14:49
React AspectRatioDiv component, guarantees a div to keep a given ratio (assuming the layout don't change over time, otherwise call syncSize, or do a raf loop to call it)
//@flow
import React, {
Component,
PropTypes,
} from "react";
const hasWindow = typeof window !== "undefined";
export default class AspectRatioDiv extends Component {
state: { width: ?number } = {