Skip to content

Instantly share code, notes, and snippets.

View bluepnume's full-sized avatar

Daniel Brain bluepnume

  • OneText
  • San Jose
View GitHub Profile
((message) => console.log(`"${ message.replace(/[\u007F-\uFFFF]/g, chr =>
'\\u' + ('0000' + chr.charCodeAt(0).toString(16)).substr(-4)
) }"`))('hello! 😀');
const randomPercentile = () => {
return Math.floor(Math.random() * 100);
};
const events = [
{
name: 'A',
percentage: 33
},

We're OneText

Good to meet you! We just started OneText

  • Jonathan Fudem is steering the ship
  • Daniel Brain is cranking out code

We're Ex-PayPal

During our combined 12 years at PayPal Checkout, we launched and scaled some of the world's most popular buying experiences.

const useElementWithSize = () => {
const [ currentElement, setCurrentElement ] = useState(null);
const [ width, setWidth ] = useState(null);
const [ height, setHeight ] = useState(null);
const updateDimensions = (element) => {
setWidth(element?.offsetWidth);
setHeight(element?.offsetHeight);
};
const mine = async () : Promise<void> => {
await loop(async () => {
const transactions = mempool.slice(0, BLOCK_SIZE_LIMIT);
const hashedBlock = await blockchain.createBlock(await keypair.publicKey, transactions);
if (hashedBlock) {
await network.broadcast('ADD_BLOCK', hashedBlock);
}
});
};
network.listen('ADD_BLOCK', async (hashedBlock) => {
mempool = [];
await blockchain.addBlock(hashedBlock);
});
const send = async (receiver : string, amount : number, fee : number) : Promise<void> => {
const signedTransaction = await signAndPack({
sender: await keypair.publicKey,
receiver,
amount,
fee
}, await keypair.publicKey, await keypair.privateKey)
await network.broadcast('ADD_TRANSACTION', signedTransaction);
};
network.listen('ADD_TRANSACTION', async (signedTransaction) => {
mempool.push(signedTransaction);
});
const keypair = KeyPair();
const network = Network();
const blockchain = BlockChain();
let mempool = [];
type BitcoinNodeType = {|
mine : () => Promise<void>,
send : (receiver : string, amount : number, fee : number) => Promise<void>
|};
export function BitcoinNode() : BitcoinNodeType
const mine = async () : Promise<void> => {
};