Skip to content

Instantly share code, notes, and snippets.

View devesh2605's full-sized avatar

Devesh Vyas devesh2605

  • Intel Corporation
  • Bangalore, India
View GitHub Profile
import React from 'react';
class OrientationDetection extends React.Component {
constructor(props) {
super(props);
this.state = {
orientation: 0
}
}
{
"events": [
{
"id": 0,
"title": "Pausha S",
"allDay": true,
"start": "2017-12-31T18:30:00.000Z",
"end": "2017-12-31T18:30:00.000Z"
},
{
@devesh2605
devesh2605 / CombineVideo.js
Created September 14, 2018 08:49
Combine videos using FFMPEG in NodeJS
const inputJson = require('./list.json'),
ffmpeg = require('fluent-ffmpeg');
const fileList = inputJson.paths;
const runFfmpeg = function(){
new Promise((resolve, reject) => {
console.log('Starting task of combining ', fileList.length, 'files');
console.log('Added file ', fileList[0], ' to the list');
const ffmpegJob = ffmpeg(fileList[0]);
@devesh2605
devesh2605 / MongoDBConnect.js
Created September 14, 2018 08:46
Connect to MongoDB using promise
const mongodb = require('mongodb');
const MongoClient = mongodb.MongoClient;
const config = require('../config/config');
const mongoUrl = config.MONGO_URL
exports.connectToDb = function () {
return new Promise((resolve, reject) => {
MongoClient.connect(mongoUrl, {
useNewUrlParser: true
}, function (err, db) {
@devesh2605
devesh2605 / Logger.js
Created September 14, 2018 08:45
Winston Logger
const winston = require('winston');
const logger = new(winston.Logger)({
transports: [
new(winston.transports.Console)({
json: false,
timestamp: true,
colorize: true,
}),
new winston.transports.File({
@devesh2605
devesh2605 / findAndDelete.js
Created September 14, 2018 08:38
Find and delete a file in NodeJS using Promise
const fs = require('fs');
const deleteFileIfExists = (path) => {
return new Promise((resolve, reject) => {
try {
fs.stat(path, (error, file) => {
if (!error && file.isFile()) {
fs.unlinkSync(path);
resolve(true);
}
const isReachable = require('is-reachable'),
nodemailer = require('nodemailer');
function checkStats() {
isReachable('api.example.com').then(reachable => {
if (reachable === true) {
console.log('Server is up');
} else {
console.log('Server is down');
const transporter = nodemailer.createTransport({
/*Strored Procedure*/
/*
CREATE PROCEDURE 'GetAllData' ()
BEGIN
SELECT * FROM Employee;
END$$
*/
/*
* Nodejs Code
var express = require('express'),
app = express(),
cors = require('cors'),
helmet = require('helmet'),
mysql = require('mysql'),
bodyParser = require('body-parser'),
crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'zyxcba',
port = 3000;