Skip to content

Instantly share code, notes, and snippets.

View iworkforthem's full-sized avatar

Wai Mun iworkforthem

View GitHub Profile
package com.ethjava;
import com.ethjava.utils.Environment;
import org.web3j.abi.FunctionEncoder;
import org.web3j.abi.FunctionReturnDecoder;
import org.web3j.abi.TypeReference;
import org.web3j.abi.datatypes.*;
import org.web3j.abi.datatypes.generated.Uint256;
import org.web3j.abi.datatypes.generated.Uint8;
import org.web3j.crypto.Hash;
var Web3 = require('web3');
var BigNumber = require('bignumber.js');
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
// set the provider you want from Web3.providers
// web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3 = new Web3(new Web3.providers.HttpProvider("https://rinkeby.infura.io/ffhOLG7Hhlvn7n8GOFPk "));
}
@iworkforthem
iworkforthem / gist:6ce597253462edbce4d1817ed58957d6
Created April 30, 2018 06:56
Get the firstDay & lastDay of each Quarter.
var today = new Date();
var quarter = Math.floor((today.getMonth() / 3));
var firstDay = new Date(today.getFullYear(), quarter * 3, 1);
var lastDay = new Date(firstDay.getFullYear(), firstDay.getMonth() + 3, 0);
@iworkforthem
iworkforthem / gist:9089b7a20bd0ed99c59d0235e09fd0f7
Created January 24, 2018 02:47
install node.js amazon linux 2
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum -y install nodejs
var url = 'http://127.0.0.1:3000/';
var headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let param = 'name=' + this.signup.username + '&email=' + '&mobile=';
this.http.post(url, param, { headers: headers }).subscribe(data => {
console.log(data)
}, error => {
console.log(error);
});
var Job = require('./model/job');
var cursor = Job.find({}).tailable().cursor();
cursor.on('data', function(doc) {
// Called once for every document
console.log(doc)
});
cursor.on('close', function(done) {
// Called when done
console.log(done)
This e-mail is meant only for the intended recipient of the transmission. Any use, dissemination, distribution, or copying of this e-mail is strictly prohibited.
This communication may contain confidential, proprietary or legally privileged information. It is intended only for the person(s) to whom it is addressed. If you are not an intended recipient, you may not use, read, retransmit, disseminate or take any action in reliance upon it. Please notify the sender that you have received it in error and immediately delete the entire communication, including any attachments. COMPANY_NAME does not encrypt and cannot ensure the confidentiality or integrity of external e-mail communications and, therefore, cannot be responsible for any unauthorized access, disclosure, use or tampering that may occur during transmission. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited. COMPANY_NAME accepts no liability for the content of this email, or for the consequences of any actions taken on the basis of the information provided.
var mongoose = require('mongoose');
mongoose.Promise = require('bluebird');
var Schema = mongoose.Schema;
var questionSchema = new Schema({
label: { type: String, default: '' },
question: { type: String, default: '' },
sudo su
curl --silent --location https://rpm.nodesource.com/setup_6.x | bash -
curl --silent --location https://rpm.nodesource.com/setup_7.x | bash -
yum remove -y nodejs npm
yum install -y nodejs