Skip to content

Instantly share code, notes, and snippets.

View gauravmehla's full-sized avatar
🚀
to the sky and beyond

Gaurav Mehla gauravmehla

🚀
to the sky and beyond
View GitHub Profile
@gauravmehla
gauravmehla / 0_reuse_code.js
Created December 6, 2016 06:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
var express = require('express');
var mongoose = require('mongoose');
var userInfo = require('../models/userInfo');
var router = express.Router();
router.post('/',function(req,res){
userInfo.find({'companyId': req.body.companyId, verified : req.body.verified },function(err,data){
if(data){
@gauravmehla
gauravmehla / 5-ways-to-check-if-a-string-contains-a-substring-in-avascript.md
Created February 28, 2017 05:00 — forked from nepsilon/5-ways-to-check-if-a-string-contains-a-substring-in-avascript.md
5 ways to check if a string contains a substring in Javascript — First published in fullweb.io issue #89

5 ways to check if a string contains a substring in Javascript

1. ES6 .includes():

var S = "fullweb";
S.includes("web");

2. RegExp .search():

angular.module('pit', ['ionic', 'ngCordova'])
.run(function($ionicPlatform, $cordovaGeolocation) {
$ionicPlatform.ready(function() {
if(window.cordova && window.cordova.plugins.Keyboard) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
// Don't remove this line unless you know what you are doing. It stops the viewport
<html><body>
<script type="text/javascript">
// Used to scale image according to aspect ratio
function calculateAspectRatioFit(srcWidth, srcHeight, maxWidth, maxHeight) {
var ratio = Math.min(maxWidth / srcWidth, maxHeight / srcHeight);
return { width: srcWidth*ratio, height: srcHeight*ratio };
}
// Calculate aspect ratio
@gauravmehla
gauravmehla / IndianCities.json
Created March 27, 2017 08:46 — forked from shubhamjain/IndianCities.json
Indian States and their Cities
{
"AP":[
"Adilabad",
"Anantapur",
"Chittoor",
"Kakinada",
"Guntur",
"Hyderabad",
"Karimnagar",
"Khammam",
@gauravmehla
gauravmehla / IndianStates.json
Created March 27, 2017 08:47 — forked from shubhamjain/IndianStates.json
Indian States and Union Territories in JSON format
{
"AP":"Andhra Pradesh",
"AR":"Arunachal Pradesh",
"AS":"Assam",
"BR":"Bihar",
"CG":"Chhattisgarh",
"Chandigarh":"Chandigarh",
"DN":"Dadra and Nagar Haveli",
"DD":"Daman and Diu",
"DL":"Delhi",
var net = require('net');
var sockets = [];
var port = 8000;
var guestId = 0;
var server = net.createServer(function(socket) {
// Increment
guestId++;
socket.nickname = "Guest" + guestId;
#! /usr/bin/env python
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
# Python P2P Chat Server |
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++|
# First we are importing some libraries which we use in our program
# You can read about each library at https://docs.python.org/3.0/library/index.html
import socket
import sys
'click .preview-image-delete': function() {
document.getElementById("fname").addEventListener("focus", myFunction);
function myFunction() {
document.getElementById("fname").style.backgroundColor = "red";
}
}