Skip to content

Instantly share code, notes, and snippets.

View pasupulaphani's full-sized avatar

Phaninder Pasupula pasupulaphani

View GitHub Profile
@pasupulaphani
pasupulaphani / after_res_hooks.js
Last active March 20, 2024 22:23
Mongoose connection best practices
var db = mongoose.connect('mongodb://localhost:27017/DB');
// In middleware
app.use(function (req, res, next) {
// action after response
var afterResponse = function() {
logger.info({req: req}, "End request");
// any other clean ups
@pasupulaphani
pasupulaphani / nginx.conf
Created December 1, 2013 23:38
Configure Nginx: Load balancing and reverse proxy
### host file under sites-available ###
# The upstream module is the link between Node.js and Nginx.
# Upstream is used for proxying requests to other servers.
# All requests for / get distributed between any of the servers listed.
upstream app_nodeapp1 {
# Set up multiple Node.js webservers for Load balancing.
# max_fails refers to number of failed attempts
@pasupulaphani
pasupulaphani / IOTA-Java-tx-example
Last active January 7, 2019 12:07
new IOTA Java API (1.0.0-beta.5) transaction example
package iotaApi;
import java.util.ArrayList;
import java.util.List;
// jota - 1.0.0-beta1
import jota.IotaAPI;
import jota.dto.response.GetNewAddressResponse;
import jota.dto.response.GetNodeInfoResponse;
import jota.error.ArgumentException;
@pasupulaphani
pasupulaphani / IOTA-NodeJs-tx-example
Created October 30, 2018 17:28
new IOTA NodeJs API (1.0.0-beta.5) transaction example
const { composeAPI } = require('@iota/core') //1.0.0-beta.5
const { asciiToTrytes } = require('@iota/converter') //1.0.0-beta.5
const iota = composeAPI({
provider: 'https://nodes.devnet.iota.org:443'
})
async function makeTx(seed, address) {
const transfers = [{
address: address,
@pasupulaphani
pasupulaphani / OraclizeAgeOfPresidentProof.sol
Last active July 17, 2018 20:21
Trusted proof of data from a datasource using Oraclize
pragma solidity ^0.4.0;
import "github.com/oraclize/ethereum-api/oraclizeAPI.sol";
contract OraclizeAgeOfPresidentProof is usingOraclize {
string public result;
constructor() {
oraclize_setProof(proofType_Android | proofStorage_IPFS);
oraclize_setCustomGasPrice(2 * 1000000000);
}
function update() payable {
@pasupulaphani
pasupulaphani / ERC20Coin.sol
Created May 27, 2018 20:08
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.24+commit.e67f0147.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract ERC20Coin{
function totalSupply() constant returns (uint256 totalSupply);
function balanceOf(address _owner) constant returns (uint256 balance);
function transfer(address _to, uint256 _value) returns (bool success);
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
04cdcdb4ca70c49ad36dd46c770b4183753d9a00b8fa2cef548b8f40375a574a7f05083d0679ddc090012c87227a99f915b56a175dea2e047033bc5a03ab9a03af
Verifying my Blockstack ID is secured with the address 1AiCWcSHLmsK9Q2yC48Jdhq5sjtvwCZwSo https://explorer.blockstack.org/address/1AiCWcSHLmsK9Q2yC48Jdhq5sjtvwCZwSo
@pasupulaphani
pasupulaphani / bunyan_logger.js
Last active July 26, 2017 22:46
bunyan sample logger
var bunyan = require('bunyan');
var config = require('./config');
var logSettings = config.logSettings;
var log = bunyan.createLogger({
name: config.app_name,
src: true,
streams : [
{
stream : process.stdout,
@pasupulaphani
pasupulaphani / nltk-intro.py
Created August 21, 2016 14:45 — forked from alexbowe/nltk-intro.py
Demonstration of extracting key phrases with NLTK in Python
import nltk
text = """The Buddha, the Godhead, resides quite as comfortably in the circuits of a digital
computer or the gears of a cycle transmission as he does at the top of a mountain
or in the petals of a flower. To think otherwise is to demean the Buddha...which is
to demean oneself."""
# Used when tokenizing words
sentence_re = r'''(?x) # set flag to allow verbose regexps
([A-Z])(\.[A-Z])+\.? # abbreviations, e.g. U.S.A.