This file contains 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
import scrapy | |
from tutorial.items import DmozItem | |
class DmozSpider(scrapy.Spider): | |
name = "dmoz" | |
allowed_domains = ["dmoz.org"] | |
start_urls = [ | |
"http://www.dmoz.org/Computers/Programming/Languages/Python/", | |
] |
This file contains 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
/* The unwanted complication on monk ('_id' as HEX 12-24 bytes) can be handled by using native mongo driver */ | |
var MongoClient = require('mongodb').MongoClient; | |
/* values to be changed as per need */ | |
var input = {'_id':'string_value'}; | |
var collection_name = 'collection_name'; | |
var db_name = 'db_name'; | |
MongoClient.connect("mongodb://localhost:27017/"+db_name, function(err, db) { |
This file contains 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
String.prototype.replaceAll = function(replace_string,replace_with){ | |
return this.split(replace_string).join(replace_with); | |
} |
This file contains 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
/* The following command will make a fork form the main process | |
It will log console data to the log file mentioned */ | |
mongod --dbpath='./data' --fork --logpath ./mongod.log |
This file contains 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 validator */ | |
var validator = require('validator'); | |
/* email id to check */ | |
var email_id = 'email@domain.com' | |
/* validator.isEmail can do the job for us */ | |
if (validator.isEmail(email_id)){ | |
console.log(' valid email '); | |
} |
This file contains 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 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 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 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 mongodb@1.4.4 | |
/* for package.json, make an entry as below */ | |
"mongodb":"^1.4.x" |
This file contains 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(); |
OlderNewer