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 / 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 / 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, '&amp;')
.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 / convertWebVTT.ps1
Last active November 7, 2021 01:58
Windows PowerShell script to Convert WebVTT to SRT
# convertWebVTT
#
# This is a very basic and incomplete WebVTT to SRT converter.
# It does not parse or understand the WebVTT elements NOTE, STYLE, REGION or any C-style comments in the WebVTT file.
#
# Save this file to your desktop as ConvertWebVTT.ps1
#
# Then create a shortcut for powershell to execute this file (change your username)
# C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -noexit -ExecutionPolicy ByPass -file C:\Users\brian\Desktop\ConvertWebVTT.ps1
@brianonn
brianonn / isArray.js
Created September 13, 2016 15:43
Array.isArray polyfill
if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) === '[object Array]';
};
}
@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 / expandpath.sh
Last active August 31, 2021 23:06
shell function for tilde expansion in a shell script. Works on Linux and OS X
#########################################
# pathname tilde expansion
# supports ~ ~/path and ~user only
# ~+ ~- and digits are not supported and
# doesn't make sense in a script anyways
# Author: Brian A. Onn
# Date: Mon 1 May 2017 06:06:43 UTC
#########################################
expandpath () {
local path="$1"
@brianonn
brianonn / rinkeby-addr.txt
Created September 24, 2017 05:17
My Rinkeby Address
0x110087600cF6bdC708CBaab5F5aCF91508Ae5eC4