Skip to content

Instantly share code, notes, and snippets.

View lukem512's full-sized avatar

Luke lukem512

View GitHub Profile
@lukem512
lukem512 / swatches.html
Created December 18, 2019 11:58
Colour Swatches Visualiser
<!doctype html>
<html>
<head>
<title>Colour Swatches</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #FAFBFC;
}
@lukem512
lukem512 / build.js
Created June 13, 2019 11:55
Mustache-based translations
const fs = require('fs');
var exec = require('child_process').exec;
const DATA = 'data/';
const TEMPLATES = 'templates/';
const OUTPUT = 'build/';
// Retrieve language from args
const args = process.argv.slice(2);
const lang = args[0];
@lukem512
lukem512 / main.cpp
Last active November 17, 2018 18:14
Ban address in Bitcoin
// Check that the destination is not banned
bool IsDestinationBanned(CScript scriptPubKey)
{
txnouttype typeRet;
vector<CTxDestination> addressRet;
int nRequiredRet;
if (!ExtractDestinations(scriptPubKey, typeRet, addressRet, nRequiredRet))
// Could not extract destinations
return true;
@lukem512
lukem512 / OP_RETURN.js
Last active May 26, 2018 07:07
OP_RETURN using Bitcore
// Extend the TransactionBuilder class to include OP_RETURN scripts.
// The two parameters are the amount to use for the output and the data
// to push onto the blockchain.
// This is done inside bitcore/lib/TransactionBuilder.js
TransactionBuilder.prototype.setUnspendableOutput = function(amount, msg) {
var valueOutSat = bignum(0);
var txobj = {};
txobj.version = 1;
txobj.lock_time = this.lockTime || 0;
txobj.ins = [];
@lukem512
lukem512 / combine-ast.js
Created June 22, 2017 10:54
Combine text elements in AST
let content = node.content;
if (Array.isArray(node.content)) {
// Combine elements of type text
content = node.content.reduce((_content, item) => {
const lastNodeIndex = _content.length - 1;
const lastNode = _content[_content.length - 1];
if (_content.length > 0 && lastNode.type === 'text' && item.type === 'text') {
_content[lastNodeIndex].content = lastNode.content + item.content;
} else {
@lukem512
lukem512 / babel.md
Created May 15, 2017 18:28
Setting up babel, a beginners guide

Setting up Babel

  1. Install babel-cli and save it to your developer dependencies
npm i --save-dev babel-cli
  1. Install a preset of your choice. Presets indicate which version of EcmaScript to use. The env preset is the most recent version.
@lukem512
lukem512 / maxcoin-validator.js
Created May 12, 2017 21:58
Validate a MaxCoin address
// node imports
var sys = require('sys');
var base58 = require('bs58');
var SHA3 = require('sha3');
// validation function
function validateAddress(address) {
// network/version byte
var version = address.substring(0, 1);
if (version != 'm') return false;
@lukem512
lukem512 / cryptodistribution.c
Created May 12, 2017 21:56
Computes cryptocurrency distribution
// Tool for working out cryptocurrency distribution rates
// Luke Mitchell, 2014
#include "stdlib.h"
#include "stdio.h"
int main (int argc, char** argv) {
printf ("Cryptodistribution tool\n");
printf ("=======================\n\n");
@lukem512
lukem512 / SvgHOC.js
Created May 12, 2017 08:19
Convert an SVG React component to React Native
/* @flow */
import React from 'react';
import Svg, {
Circle,
Ellipse,
G,
LinearGradient,
RadialGradient,
@lukem512
lukem512 / Emoji Consensus.md
Created May 11, 2017 09:52
Democratic consensus using Emoji

Emoji Consensus

👍 I concur! I agree with the proposal.

👎 Veto! I disagree with the proposal.

👉 I feel this needs more discussion.

👊 I have no opinion or don't wish to participate in this decision.