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
/* protos.js*/ | |
var hey = function(){ | |
} | |
hey.prototype.sayHey = function(){ | |
console.log('Hey'); | |
} |
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
var async = require("async"); | |
//series calls the final callback function on every successful execution of the function in the list. | |
async.series([ | |
function(callback) { | |
setTimeout(function() { | |
console.log("Task 1"); | |
callback(null, 1); | |
}, 300); |
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 async = require('async'); | |
async.waterfall( | |
[ | |
function(callback) { | |
callback(null, 'Yes', 'it'); | |
}, | |
function(arg1, arg2, callback) { | |
var caption = arg1 +' and '+ arg2; | |
callback(null, caption); |
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
/* | |
If your package.json file contains "start": "node ./bin/www" | |
Use the following command to bring up your app with forever | |
*/ | |
forever start --minUptime 1000 --spinSleepTime 1000 ./bin/www | |
/* Check list of forever process using the command */ | |
forever list |
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 dns */ | |
var dns = require('dns'); | |
/* domain name to lookup */ | |
domain_name = 'example.com'; | |
dns.lookup(domain_name, function(err, addresses, family){ | |
/* handle if look up fails inside if condition */ | |
if(err){return console.log(err.stack);} |
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 '); | |
} |
OlderNewer