Skip to content

Instantly share code, notes, and snippets.

@boutell
boutell / nestedapps.js
Created December 31, 2012 22:41
Nested Express apps. The "Main Wildcard" route always beats all routes in catsApp even though it is added first with app.use. I wish app.use() had the same precedence as adding a route.
// HOPED-FOR BEHAVIOR: /cats says: Cats Home
// ACTUAL BEHAVIOR: /cats says: Main Wildcard
var express = require('express');
var app = express();
app.get('/', function(req, res) {
res.send('Main Home');
})
@imjasonh
imjasonh / markdown.css
Last active May 17, 2024 07:30
Render Markdown as unrendered Markdown (see http://jsbin.com/huwosomawo)
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@olih
olih / jq-cheetsheet.md
Last active May 15, 2024 22:26
jq Cheet Sheet

Processing JSON using jq

jq is useful to slice, filter, map and transform structured json data.

Installing jq

On Mac OS

brew install jq

@tomconte
tomconte / compile-deploy-sign.js
Created January 3, 2017 14:25
Shows how to compile and deploy a Smart Contract using client-side transaction signature, i.e. does not require the account to be unlocked in the Ethereum node.
const fs = require('fs');
const solc = require('solc');
const Web3 = require('web3');
const Tx = require('ethereumjs-tx')
// Private key to use to sign the transactions
// To decrypt your private key, use e.g. https://www.myetherwallet.com/#view-wallet-info
// You will find your private key file in e.g. .ethereum/keystore or .parity/keys
// In this example the key should correspond to the web3.eth.coinbase address
var privateKey = new Buffer('088c110b6861b6c6c57461370d661301b29a7570d59cb83c6b4f19ec4b47f642', 'hex')
@jcavat
jcavat / Dockerfile
Last active February 25, 2024 13:58
docker-compose with php/mysql/phpmyadmin/apache
FROM php:7.1.2-apache
RUN docker-php-ext-install mysqli
@emschwartz
emschwartz / README.md
Last active September 28, 2019 11:28
1st ETH -> XRP Interledger Escrow Payment

1st ETH -> XRP Interledger Escrow Payment

Here are the transaction IDs (and links to the block explorers) for the first livenet Ethereum and Ripple Consensus Ledger (RCL) escrowed transfers comprising an Interledger payment.

  1. Ethereum prepare: 0x00cbb6149b9cfb3cedf280251c3060b2a38776fa7792b578b6f9f39ce5ee0266
  2. RCL prepare: 7F0A5F16C84568D96DA6A66058CD9EAA881236237642BF7427A458957A752B6B
  3. RCL fulfill: 12A4CAFAE95254844513C5C11488A1195C08DEFF673C97AC74AAC121935DDE36
  4. Ethereum fulfill: 0xb59dd839ab0b5e7d4e663b7cfc0ddb70eaf73dd2785b3d3a4abdf1a61817007d

SHA-256 Condition: `d2

@VictorTaelin
VictorTaelin / upload_json_to_ipfs.js
Last active December 30, 2021 20:09
Upload a JSON to IPFS
const ipfs = require("nano-ipfs-store").at("https://ipfs.infura.io:5001");
(async () => {
const doc = JSON.stringify({
foo: "bar",
tic: "tac"
});
const cid = await ipfs.add(doc);
@sogoiii
sogoiii / ListenToEventsWeb3-1-0-0-beta.js
Last active December 26, 2023 23:00
Listening to Solidity events using web3 1.0.0 beta
const Web3 = require('web3') // Works with web3 1.0.0-beta27
const contractArtifact = require('./build/contracts/TutorialToken.json')
const web3 = new Web3()
const providerUrl = 'ws://localhost:8545' // requires # https://github.com/trufflesuite/ganache-cli/releases/tag/v7.0.0-beta.0 or https://github.com/trufflesuite/ganache/releases/tag/v1.1.0-beta.0
const provider = new Web3.providers.WebsocketProvider(providerUrl)
web3.setProvider(provider)
web3.eth.net.getId()
.then(networkId => {
@goloroden
goloroden / app.js
Last active June 22, 2023 02:10
Async constructors for JavaScript
// In JavaScript, constructors can only be synchronous right now. This makes sense
// from the point of view that a constructor is a function that returns a newly
// initialized object.
//
// On the other hand, it would sometimes be very handy, if one could have async
// constructors, e.g. when a class represents a database connection, and it is
// desired to establish the connection when you create a new instance.
//
// I know that there have been discussions on this on StackOverflow & co., but
// the so-far mentioned counter arguments (such as: doesn't work as expected
@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