Skip to content

Instantly share code, notes, and snippets.

View harpreetkhalsagtbit's full-sized avatar

Harpreet Singh harpreetkhalsagtbit

View GitHub Profile
@harpreetkhalsagtbit
harpreetkhalsagtbit / GeoNameJsonIndianStates
Created May 29, 2014 09:45
Indian States Geo Names JSON
[
{
"name": "Andaman and Nicobar Islands",
"code": "AN"
},
{
"name": "Andhra Pradesh",
"code": "AP"
},
{
@harpreetkhalsagtbit
harpreetkhalsagtbit / GeoNamesCountries
Last active December 29, 2015 13:32
Geo Names Countries
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Åland Islands",
"code": "AX"
},
{
@harpreetkhalsagtbit
harpreetkhalsagtbit / dynamicMongooseMultipleQuerie
Last active April 6, 2021 08:02
Running multiple Mongodb/mongoose queries - dynamiclly using async.js
// working example mongoose
var PersonSchema = new Schema({
name : String,
age : Number,
});
var StorySchema = new Schema({
title : String,
});
var Story = mongoose.model('Story', StorySchema);
var Person = mongoose.model('Person', PersonSchema);
@harpreetkhalsagtbit
harpreetkhalsagtbit / populateMultipleTables.js
Last active August 29, 2015 14:02
Populate Multiple Tables - Result of each populate is an array
// working example mongoose
var tableASchema = new Schema({
template : String,
description : String
});
var tableBSchema = new Schema({
group : String,
a_pk : [{ type: Schema.ObjectId, ref: 'tableA' }],
@harpreetkhalsagtbit
harpreetkhalsagtbit / saveAndPushIdAndSaveParent.js
Created June 22, 2014 17:43
Save after push to a refrence model
var async = require('async');
global._clients = {};
var mongoose = require('mongoose');
global._mongoose = mongoose;
var conf = {
db: {
db: 'gendocx',
host: 'localhost',
@harpreetkhalsagtbit
harpreetkhalsagtbit / Selenium - TheIntern.md
Last active November 23, 2015 06:14
Automate Testing - TheIntern.io Selenium Functional Testing Example including Seting Up Environment

Automate Testing using - TheIntern.io and Selenium locally

Note: This tutorial focus on Automate Functional Testing on Ubuntu.

Environment Setup:

  • Install : JDK - Java .
  • Download: Selenium server - a *.jar file from this Link.
@harpreetkhalsagtbit
harpreetkhalsagtbit / Automate Testing of Meteor application with TheIntern.md
Last active January 25, 2016 14:12
Automate Testing of a Meteor Application using TheIntern.io

Testing Meteor Application with TheIntern.io

Problem

  1. Where to place tests folder and npm packages in Meteor folder structure so that they won't run with meteor command.

  2. How to access Meteor global variable and Meteor Collections.

  3. How to run tests?

@harpreetkhalsagtbit
harpreetkhalsagtbit / My Research on ELM.md
Last active September 26, 2016 10:53
My Research on ELM - 3/10 Marks to 8/10 Marks

My Research on ELM - Mail to my Boss - 9 June 2016

I have gone through so many articles related to elm from past few days. My affinity for using elm, had many ups and down as I gone through different articles.

The very first opinion, after reading One or Two articles related to Elm was:

  1. We need to learn a Totally New and Different syntax.
  2. People are comparing Elm with React --- How? Some are even saying it better that React - How?
  3. How to train other developers, how to convince other for using Elm(even I am not convinced yet). People are comfortable using HTML/CSS directly. Its not easy for everyone for a transition like this.
@harpreetkhalsagtbit
harpreetkhalsagtbit / charfreq.js
Created September 30, 2016 16:33
count consecutive char freq
var k = "aaahhrrrvfuuhh".split("")
var ref = k[0]
var newStr = ''
while(k.length) {
for(var i=0;i<k.length;i++) {
if(k[i] != ref) {
console.log(k[i] , ref, i)
k = k.splice(i,k.length - 1)
if(i > 1) {
@harpreetkhalsagtbit
harpreetkhalsagtbit / Component.js
Last active September 26, 2017 13:13
Stateless Component - Interaction with parent's state
import React from 'react';
import TextInput from '../../common/TextInput';
import PropTypes from 'prop-types'; // ES6
import './Add.css';
const AddUrl = ({urlShortForm, saveURLHandler, triggerPreviewURL}) => {
var _changeInterval = null;
let onKeyUpAddShortUrlTextInput = function(event) {