Skip to content

Instantly share code, notes, and snippets.

View iworkforthem's full-sized avatar

Wai Mun iworkforthem

View GitHub Profile
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.
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.
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)
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);
});
@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
@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);
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 "));
}
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;
@iworkforthem
iworkforthem / README-Template.md
Created November 13, 2018 09:03 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

// call external API
await this.getWeather(turnContext);
// external API via axios
async getWeather(turnContext) {
const axios = require('axios');
try {
const response = await axios.get('https://api.data.gov.sg/v1/environment/psi');
console.log(response.data);
await turnContext.sendActivity('The weather is ' + response.data.api_info.status);