Skip to content

Instantly share code, notes, and snippets.

View Harshakvarma's full-sized avatar
🎯
Focusing

Harshavardhan Kalidindi Harshakvarma

🎯
Focusing
View GitHub Profile
@Harshakvarma
Harshakvarma / splitJson.js
Created February 19, 2018 03:31
Splitting a large json file into small files
if(process.argv.length < 3){
console.log('target file path is required.')
process.exit(1)
}
var target = process.argv[2]
console.log('file: ' + target)
var fs = require('fs')
fs.readFile(target, function (err, data) {
@Harshakvarma
Harshakvarma / model|User.js
Last active February 4, 2018 20:53
Sequelize example
module.exports = function(sequelize, Sequelize) {
var User = sequelize.define('user', {
id: { autoIncrement: true, primaryKey: true, type: Sequelize.INTEGER},
firstname: { type: Sequelize.STRING,notEmpty: true},
lastname: { type: Sequelize.STRING,notEmpty: true},
username: {type:Sequelize.TEXT},
about : {type:Sequelize.TEXT},
email: { type:Sequelize.STRING, validate: {isEmail:true} },
password : {type: Sequelize.STRING,allowNull: false },
@Harshakvarma
Harshakvarma / Aysnc Await nodejs syncronous Even Odd numbers
Created January 23, 2018 22:46
Using aysnc await features in Nodejs (ES6 Javascript) created Even Odd filter of random numbers
randomArray = Array.from({length: 10}, () => Math.floor(Math.random() * 40));
console.log("Random: ",randomArray);
var even = [];var odd = [];
processArray(randomArray)
async function processArray(data) {
for(const item of data){
// console.log(item)
await asyncCall(item)
@Harshakvarma
Harshakvarma / App.js
Created January 15, 2018 06:42
Axios react API subreddit demo
import React from 'react';
import ReactDOM from 'react-dom';
import axios from 'axios';
class FetchDemo extends React.Component {
constructor(props) {
super(props);
this.state = {
posts: []