Skip to content

Instantly share code, notes, and snippets.

View scizers's full-sized avatar

Ishaan Sharma scizers

View GitHub Profile
@scizers
scizers / bash-smtp-auth-email
Created April 28, 2016 13:28 — forked from fbatschi/bash-smtp-auth-email
How to send an email from bash via SMTP Auth
echo "PUT YOUR MAIL BODY HERE" | mailx -s "SUBJECT" -S smtp=smtp://yoursmtpserver.com -S smtp-auth=login -S smtp-auth-user=YOUR_USERNAME -S smtp-auth-password=YOUR_PASSWORD -S from="Sender Name <[email protected]>" [email protected]
@scizers
scizers / cros.js
Created March 1, 2015 18:19
Cross Origin policy
app.get('/questions/intTags' , function (req ,res) {
console.log(req.query.data)
var data = [
{ "text": "Tag1" },
{ "text": "Tag2" },
{ "text": "Tag3" },
{ "text": "Tag4" },
{ "text": "Tag5" },
{ "text": "Tag6" },
{ "text": "Tag7" },
@scizers
scizers / model.js
Last active August 29, 2015 14:14
auto increment with two queries
var mongoose = require('mongoose');
var counter = mongoose.Schema({
type: { type: String, index: { unique: true }},
seq: Number
});
// create the model for users and expose it to our app
module.exports = mongoose.model('counter', counter);
@scizers
scizers / mongod.txt
Last active September 9, 2017 23:18
add admin user to mongodb
use admin
db.createUser(
{
user: "admin",
pwd: "alum123#",
roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
}
)
db.createUser(
@scizers
scizers / autofit.js
Created January 23, 2015 19:21
autofit text angaularjs directive
app.directive('autofit', function(){
return function(scope, element, attrs){
var span = element.find('span:visible:first');
var maxHeight = element.height();
var maxWidth = element.width();
var originalFontSize = parseInt(element.css('font-size').replace('px',''),10);
@scizers
scizers / skip morgan logging
Created January 21, 2015 09:16
morgan version > 1.4.0
var rejectFolders = ['css', 'bower_components' , 'js', 'fonts' , 'assets']
app.use(morgan('tiny', {
skip: function (req, res) {
if(rejectFolders.indexOf(req.url.split('/')[1]) != -1 ){
return true
} else {
return false
}
@scizers
scizers / checkimages404.js
Last active August 29, 2015 14:13
Check if Image exists on Url while crawling
var validUrl = require('valid-url');
if(validUrl.isUri(imageUrl)){
request
.get(imageUrl)
.on('response', function (response) {
console.log(response.statusCode)
imagesName = (imagesName.split('?')[0])
if (response.statusCode == 200) {
@scizers
scizers / Ejs Title Generator
Created December 8, 2014 07:25
Generate Title from routes path in ejs
res.locals.titleGenerator = function () {
var urlPath = (req.route.path).split('/')
var urlName = urlPath[1];
function capitalizeEachWord(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
@scizers
scizers / index.html
Created December 2, 2014 10:51
Angularjs DateRangePicker
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="components/bootstrap-daterangepicker/daterangepicker-bs3.css">
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://raw.githubusercontent.com/dangrossman/bootstrap-daterangepicker/master/moment.js"></script>
@scizers
scizers / SimulateClick.js
Last active August 29, 2015 14:06
Simulate Click in jQuery
jQuery(document).ready(function(){
setTimeout(function(){
jQuery.fn.simulateClick = function() {
return this.each(function() {
if('createEvent' in document) {
var doc = this.ownerDocument,
evt = doc.createEvent('MouseEvents');