Skip to content

Instantly share code, notes, and snippets.

View adrianmcli's full-sized avatar
:shipit:
What's happening?

Adrian Li adrianmcli

:shipit:
What's happening?
View GitHub Profile
const { getWeb3, getContractInstance } = require("./helpers")
const web3 = getWeb3()
const getInstance = getContractInstance(web3)
contract("Counter", (accounts) => {
it("should initialize with a count of 0", async () => {
const counter = getInstance("Counter")
const count = await counter.methods.get().call()
const expected = 0
const Counter = artifacts.require("Counter")
contract("Counter", (accounts) => {
it("should initialize with a count of 0", async () => {
const counter = await Counter.deployed()
const count = await counter.get.call()
const expected = 0
assert.equal(count, expected, "count was not initialized with 0")
@adrianmcli
adrianmcli / output.txt
Last active March 5, 2020 01:32
script for tracking network requests from a website
https://www.googletagservices.com/tag/js/gpt.js
https://www.googletagmanager.com/gtm.js?id=GTM-MNVXW26
https://c.amazon-adsystem.com/aax2/apstag.js
https://ap.lijit.com/rtb/bid?src=prebid_prebid_0.34.0
https://coinmarketcap-d.openx.net/w/1.0/arj?ju=https%3A%2F%2Fcoinmarketcap.com%2F&jr=https%3A%2F%2Fcoinmarketcap.com%2F&ch=UTF-8&res=1366x768x24&ifr=false&tz=-540&tws=800x600&ef=bt%252Cdb&be=1&bc=hb_pb_2.0.0&nocache=1526994145454&auid=539181151%2C539181149&dddid=0127ceee-84dd-4e77-8998-28605400c347%2C0624d006-e24f-4dc6-b4c5-80f14ae24698&aus=160x600%7C728x90&
https://as-sec.casalemedia.com/cygnus?v=7&fn=cygnus_index_parse_res&s=219064&r=%7B%22id%22%3A%2274103715%22%2C%22site%22%3A%7B%22page%22%3A%22https%3A%2F%2Fcoinmarketcap.com%2F%22%7D%2C%22imp%22%3A%5B%7B%22id%22%3A%221%22%2C%20%22banner%22%3A%7B%22w%22%3A728%2C%22h%22%3A90%2C%22topframe%22%3A1%7D%2C%22ext%22%3A%20%7B%22sid%22%3A%221_1%22%2C%22siteID%22%3A219064%7D%7D%2C%7B%22id%22%3A%222%22%2C%20%22banner%22%3A%7B%22w%22%3A160%2C%22h%22%3A600%2C%22topframe%
@adrianmcli
adrianmcli / transform.js
Last active May 9, 2018 18:23
just a simple function to transform a typical 0x order object into the form we need.
const transform = ({
exchangeContract,
expiration,
feeRecipient,
salt,
maker,
taker
}) => ({
exchangeContractAddress: exchangeContract,
expirationUnixTimestampSec: expiration,
@adrianmcli
adrianmcli / EXAMPLES.md
Last active February 21, 2018 07:55
Concrete use-case examples for b0x.network.

Examples

Please note that WETH and ETH will be used interchangeably in the following discussion.

The b0x network allows anyone with ERC20 tokens to loan it out for interest on a margin trading platform.

Example 1: Alice holds a lot of ETH tokens and instead of letting it sit, she wants to lend it to traders who are looking to borrow money so that they can trade on margin. Alice creates a b0x order specifying the type of token she is lending out (i.e. loanToken) and the type of token that she wants the interest to be paid in (i.e. interestToken).

The lender can specify the specific margin amounts that the borrower must have in order to fill the order and maintain the loan.

@adrianmcli
adrianmcli / Navbar.jsx
Created December 15, 2017 23:47
Fixed topnav navbar example with responsive side menu.
import React from "react";
import styled from "styled-components";
const Container = styled.nav`
background: darkred;
/* make this a fixed navbar at the top, with fixed height */
position: fixed;
top: 0;
right: 0;
@adrianmcli
adrianmcli / bootstrap_grail.jsx
Created December 15, 2017 22:33
A width-constrained SPA layout with CSS Grid in React and Styled-Components
import React from "react";
import styled from "styled-components";
const Container = styled.div`
/* make it full height and width */
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
@adrianmcli
adrianmcli / UserIsTypingIndicator.js
Created December 3, 2017 01:53
A typing indicator with spinner animation using RxJS in React.
import React from "react";
import styled, { keyframes } from "styled-components";
import { Subject } from "rxjs/Subject";
import "rxjs/add/operator/do"
import "rxjs/add/operator/debounceTime"
const rotate360 = keyframes`
from {
transform: rotate(0deg);
}
@adrianmcli
adrianmcli / Spinner.js
Created December 3, 2017 01:26
Dead simple loading spinner with just CSS in styled-components.
import styled, { keyframes } from "styled-components";
const rotate360 = keyframes`
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
@adrianmcli
adrianmcli / withWeb3Usage.js
Created November 27, 2017 19:06
Usage example of the withWeb3 HOC
import React from 'react'
import withWeb3 from './withWeb3'
const MyComponent = ({ web3 }) =>
<div>
<h1>My Dapp</h1>
<pre>{JSON.stringify(web3, null, 4)}</pre>
</div>
export default withWeb3(MyComponent)