This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* npm install dns */ | |
var dns = require('dns'); | |
/* domain name to check for record */ | |
domain_name = '<domain-name>'; | |
/* dns.resolveMx can do the job for us */ | |
dns.resolveMx(domain_name, function(err, addresses){ | |
if(err){ return console.log(err.stack);} | |
console.log(addresses); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Changing first letter of string to uppercase */ | |
String.prototype.toFirstUpperCase = function(){ | |
return this.slice(0,1).toUpperCase()+this.slice(1); | |
} | |
/* Usage */ | |
"example".toFirstUpperCase(); //Example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* iptable rule for droping connections through eth0 to all ports except 22(ssh) */ | |
>> iptables -A INPUT -i eth0 -p tcp ! --dport 22 -j DROP | |
/* Check applied rule */ | |
>> iptables -L | |
target prot opt source destination | |
DROP tcp -- anywhere anywhere tcp dpt:!ssh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* install nginx */ | |
>>sudo apt-get install nginx | |
/* comment out other line and add configurations to the below file */ | |
>>sudo vi /etc/nginx/sites-available/default | |
/* list of server to be added to upstream */ | |
upstream backend { | |
server <IPADDRESS1>:<PORT>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select replace(substring(`email_field`, LOCATE('<', `email_field`)+1),substring(`email_field`, LOCATE('>', `email_field`)),'') from table_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* installing below version of mongodb can fix the problem for now */ | |
npm install [email protected] | |
/* for package.json, make an entry as below */ | |
"mongodb":"^1.4.x" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongo = require('mongodb'); | |
var monk = require('monk'); | |
var db_name = '' | |
var db = monk('localhost:27017/'+db_name); | |
var collection = db.get('collection_name'); | |
collection.find({}, function(err,docs){ | |
console.log(docs); | |
db.close(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* This can be used if the table doesn't have an existing Primary Key */ | |
SELECT @s:=@s+1 as id, <table-name>.* from <table-name>, (SELECT @s:= 0) as s; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongo = require('mongodb'); | |
var monk = require('monk'); | |
var Promise = require('bluebird'); | |
/* DB connection */ | |
var dbName = '' | |
var db = monk('localhost:27017/'+dbName); | |
/* replace <collection-name> with your collection*/ | |
var collection = db.get(<collection-name>); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iptables -A INPUT -p tcp -s localhost --dport 27017 -j ACCEPT | |
iptables -A INPUT -p tcp --dport 27017 -j REJECT |