Skip to content

Instantly share code, notes, and snippets.

View djl-gg's full-sized avatar
🎯
Focusing

dj djl-gg

🎯
Focusing
View GitHub Profile
{
"network-configs": {
"network-1": {
"version": "1.0",
"clients": {
"client-1": {
"tlsEnable": false,
"organization": "Org1MSP",
"channel": "mychannel",
"credentialStore": {
0xA970dcEa3F1EAa08B5225c71A9b11E456c56f9aE
@djl-gg
djl-gg / sendRawTransaction.js
Created June 15, 2018 20:46
Call and sign a function with web3 1.0+ and Infura API from nodejs
const Web3 = require("web3");
const EthereumTransaction = require("ethereumjs-tx");
const mainArtifact = requir("./build/contracts/Main.json");
const OWNER_ADDRESS = "OWNER_ETHEREUM_ADDRESS";
const PRIVATE_KEY = "PRIVATE_KEY_OF_OWNER_ETHEREUM_ADDRESS";
const CONTRACT_ADDRESS = "MAIN_CONTRACT_ADDRESS";
// Local (Ganache cli) or Infura API
const web3 = new Web3(
const d3 = require('d3');
(function() {
d3.layout.grid = function() {
var mode = "equal",
layout = _distributeEqually,
x = d3.scale.ordinal(),
y = d3.scale.ordinal(),
size = [1, 1],
actualSize = [0, 0],
function Node() {
this.value = 5;
this.next = [object Object];
}
function recurseNodes(num, node) {
if(node.next === null) return false;
if(node.value === num) return true;
@djl-gg
djl-gg / rps.js
Created March 21, 2016 02:18
rps
/**
* returns every sequence of throws a single player could throw over a three-round game of rock-paper-scissors
* rockPaperScissors(1); -> [['rock'],['paper'],['scissors']]
* rockPaperScissors(2); ->
* [['rock','rock'],['rock','paper'],['rock','scissors'],
* ['paper','paper'],['paper','scissors'],['paper','rock'],
* ['scissors','scissors'],['scissors','paper'],['scissors','rock']]
*/
function rockPaperScissors(num) {
var results = [],
@djl-gg
djl-gg / coinSum.js
Created March 21, 2016 02:18
coinSum
/*
In England the currency is made up of pound, £, and pence, p, and there are eight coins in general circulation:
1p piece
2p piece
5p piece
10p piece
20p piece
50p piece
@djl-gg
djl-gg / binary.js
Created October 5, 2015 19:18
Tree Data Structure Problem
function Node(data, leftChild, rightChild) {
this.data = data || null;
this.left = leftChild || null;
this.right = rightChild || null;
}
function Tree(rootNode) {
this.rootNode = null;
}
@djl-gg
djl-gg / Single and Double Parameters
Created September 14, 2015 14:47
Filter Method Example
//stackoverflow filter method example
a = [5, 4, 3, 2, 1]; // array 5,4..1
smallvalues = a.filter(function(x) { return x < 3 }); // [2, 1] return value
everyother = a.filter(function(x,i) { return i%2==0 }); // [5, 3, 1] return value
//The first one reads: »return me every element (x), which is lesser than 3«. The result is not astounding.
//The second one reads: »return me every element, whose index (i) is even (including 0)«
@djl-gg
djl-gg / gist:0ecd299c76c5e1fc763d
Created September 12, 2015 18:32
Prototype and Inheritance example
function Shape(a, b) {
this.x = a;
this.y = b;
}
Shape.prototype.getPosition = function () {
return [this.x, this.y];
};
function Circle(a, b) {