Skip to content

Instantly share code, notes, and snippets.

View bitgord's full-sized avatar

Michael Gord bitgord

View GitHub Profile
@bitgord
bitgord / queryParams.js
Created December 13, 2016 02:35
Get Query Params Third Party Lib
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split('&');
for (var i=0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (decodeURIComponent(pair[0]) == variable) {
return decodeURIComponent(pair[1]);
}
}
@bitgord
bitgord / Create-Ripple-Wallet-Javascript
Last active December 12, 2016 03:19
Build a Ripple Wallet from Scratch Using Javascript
// Node must be downloaded
// Install Ripple-Wallet package
npm install ripple-wallet
// In a node terminal require ripple wallet
var lib = require('ripple-wallet')
// Generate a Wallet
var RippleWallet = require('ripple-wallet')
RippleWallet.generate();
@bitgord
bitgord / Quick-Nodejs-Ripple-Lib-Setup
Created December 12, 2016 02:58
Quick Setup of Ripple Lib with Nodejs to Query the Ripple API
// Node must be downloaded to beign
// Install ripple-lib // A JavaScript API for interacting with Ripple in Node.js and the browser
npm install ripple-lib
// In Node require ripple-lib
const {RippleAPI} = require('ripple-lib');
// The object that is returned contains all the functionality to query the ripple network
// First you must connect to Ripples servers // Run this from node terminal
@bitgord
bitgord / Quick-ES6-Setup-Heroku
Created December 12, 2016 02:36
Quick setup to use ES6 with Heroku
// First download node, create new folder
// Cd into new folder, npm and git init
// Create heroku app
heroku create
// install babel cli (to do compiling), babel presets (to compile the right features), express (web server)
npm install babel-cli babel-presets-es2015 express
// Create file .babelrs and add json
@bitgord
bitgord / Quick-ES6-Setup
Created December 11, 2016 21:27
Quick setup of a ES6 environment with nodemon and babel
// First you need to have node version 5 or newer
// Create a new project folder with a package.json file
mkdir [[new project name]]
cd [[new project name]]
npm init
// Install babel
npm install babel-preset-es2015
@bitgord
bitgord / Quick-MongoLab-Setup
Created December 11, 2016 21:02
Quick setup of a MongoLab database
// Node and npm are required for this gist
// Install mongoose
npm install mongoose
// On https://mlab.com/create click on Free Sandbox and give your DB a name
// You are then given a database on the next screen
// Give your database a new username and password
// The mongo shell and MongoDB URI should now be visible
@bitgord
bitgord / Create-Bitcoin-Address-NodeJS-BitcoinJS
Last active March 17, 2020 20:01
Create a bitcoin address with Nodejs and Bitcoinjs
// You must have node and npm downloaded on your computer
// Download bitcoinjs library
npm install bitcoinjs-lib
// Require bitcoinjs-lib
var bitcoin = require("bitcoinjs-lib");
// Make variable for keyPair
var keyPair = bitcoin.ECPair.makeRandom();
@bitgord
bitgord / Blockchain-Embed-Data-Bitcore
Last active July 15, 2019 09:03
Embed data in the bitcoin blockchain using butcher
// download bitcore-lib
npm install bitcore-lib
// require bitcore
var bitcore = require("bitcore-lib");
// copy the code from BitPay's example to create an OP RETURN
var privateKey = new bitcore.PrivateKey('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy');
var utxo = {
"txId" : "115e8f72f39fad874cfab0deed11a80f24f967a84079fb56ddf53ea02e308986",
@bitgord
bitgord / Blockchain.Info-API-Nodejs
Last active June 18, 2018 22:19
Query the Blockchain.info API with Nodejs
// require express to connect server
var express = require("express");
var app = express();
// require request to connect to blockchain.info api
var request = require("request");
// request blockchain.info api in json and save api data in variables
request({
url: "http://blockchain.info/stats?format=json",
@bitgord
bitgord / Intro-Bitfinex-API-Websockets
Created December 10, 2016 21:11
Get Bitfinex API data with Websockets
// First go to http://docs.bitfinex.com and click on the websockets tab
// Scroll down and find the SSL websocket connection URL
For example: wss://api.bitfinex.com/ws
// In a new Javascript file create a variable for new websocket
var ws = new WebSocket('wss://api.bitfinex.com/ws');
// Create function to send on open
ws.onopen = function() {
ws.send(JSON.stringify({"event":"subscribe", "channel":"ticker", "pair":"BTCUSD"}));