Skip to content

Instantly share code, notes, and snippets.

View brianonn's full-sized avatar

Brian Onn brianonn

  • Vancouver, Canada
View GitHub Profile
@brianonn
brianonn / encodeHTML.js
Last active January 2, 2016 16:30
JS: escape XML
//credits zzzzBov http://stackoverflow.com/questions/7918868/how-to-escape-xml-entities-in-javascript
if (!String.prototype.encodeHTML) {
String.prototype.encodeHTML = function () {
return this.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
.replace(/"/g, '&quot;')
.replace(/'/g, '&apos;');
};
}
@brianonn
brianonn / mkpw.sh
Created January 2, 2016 16:52
SH: function for making random passwords
## put this into your ~/.bashrc file and make random passwords as needed.
##
## usage:
## mkpw <length>
##
## ex: for for i in $(seq 5);do mkpw 10 ; done
## Rw3QPaeUM2
## qPgQnx5K38
## wZnOZjQsdN
## H0tcr1tVrQ
@brianonn
brianonn / 0_reuse_code.js
Created January 2, 2016 17:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@brianonn
brianonn / build-bitcoin.sh
Created September 29, 2016 11:15
how to build bitcoin (0.13) on a new Ubuntu install
#!/bin/bash
# building bitcoin (for 0.13)
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev
sudo apt-get install libboost-program-options-dev libboost-test-dev libboost-thread-dev
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools
sudo apt-get install libprotobuf-dev protobuf-compiler libminiupnpc-dev libzmq3-dev libdb++-dev
sudo apt-get install git emacs
diff --git a/src/main.cpp b/src/main.cpp
index 37ad1db..905a14d 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2951,6 +2951,42 @@ bool InitBlockIndex() {
printf("Got: block.GetHash() = %s\n", hash.ToString().c_str());
printf("Got: block.hashMerkleRoot = %s\n", block.hashMerkleRoot.ToString().c_str());
+ // BEGIN MINING THE GENESISBLOCK
+ // If genesis block hash does not match, then generate new genesis hash.
@brianonn
brianonn / ISODateString.js
Last active January 31, 2017 05:10
JS: create an ISO8601 date string
//credits: http://stackoverflow.com/questions/2573521/how-do-i-output-an-iso-8601-formatted-string-in-javascript
// params: d - a javascript Date object
// example: sTimestamp = ISODateString(new Date)
function ISODateString(d) {
function pad(n) {
return n < 10 ? '0' + n : n;
}
return d.getUTCFullYear() + '-'
+ pad(d.getUTCMonth() + 1) + '-'
@brianonn
brianonn / rinkeby-addr.txt
Created September 24, 2017 05:17
My Rinkeby Address
0x110087600cF6bdC708CBaab5F5aCF91508Ae5eC4
@brianonn
brianonn / VUIToken.sol
Last active December 11, 2017 08:02
VUI ERC 20
pragma solidity ^0.4.18;
/**
* Welcome to the Telegram chat http://www.devsolidity.io/
*/
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
@brianonn
brianonn / testframe.html
Created December 19, 2017 01:07
test loading XHR content into an iframe
<div id='body'>
<h1>this is a header</h1>
<iframe id='iframe' />
</div>
<p id='responseText'>
</p>
@brianonn
brianonn / alarm.js
Created January 9, 2018 02:45
play an alarm in 15 mins
function myFunction () {
console.log('Executed!');
var source = "https://firebasestorage.googleapis.com/v0/b/aminsbd-96be5.appspot.com/o/alarm.mp3?alt=media&token=c7597653-7d8b-44c6-9bb2-e8b9301dfe55"
var audio = document.createElement("audio");
//
audio.autoplay = true;
//
audio.load()
audio.addEventListener("load", function() {
audio.play();