Skip to content

Instantly share code, notes, and snippets.

View VarunBatraIT's full-sized avatar
🏠
Working from home

Varun Batra VarunBatraIT

🏠
Working from home
View GitHub Profile
@VarunBatraIT
VarunBatraIT / spicegems.md
Last active December 27, 2021 11:40
PHP Assignment SpiceGems

Collect all the under roots (Square Root: For instance 4 under root is 2) of all the positive integers between 1 to 100000 which are prime numbers in an array. Randomize the order of an array such that only ONE random triplet is in original order with exact same indices.

For instance, if input would have been 50, under root array would have been as following in ascending order:

$input = 50;
$ordered_output = [1, 2, 3, 5, 7];

and after randomize output would have been any one of the following but random everytime:

version: '2'
services:
mysql:
image: bitnami/mysql:latest
container_name: MySQL
user: "0:0"
restart: always
environment:
MYSQL_ROOT_PASSWORD: "mbstf"
MYSQL_AUTHENTICATION_PLUGIN: mysql_native_password
@VarunBatraIT
VarunBatraIT / Assignment.md
Last active October 24, 2018 14:50
Basic Assignment

1

  • Use php to create 100 divs such that all the values inside divs must be a prime number in descending order starting from 99991.
  • Write a jQuery function which will hide the div is a user clicks on any of the prime number.

2

  • Create a PhysicalProduct class with all the necessary functionality.
  • Create a DigitalProduct class with all the necessary functionality.
  • Create a Cart class with all the necessary functionality which supports multiple carts - can add PhysicalProduct and DigitalProduct.
Array.from(document.querySelectorAll('*'))
.reduce(function(pre, dom){
var evtObj = getEventListeners(dom)
Object.keys(evtObj).forEach(function (evt) {
if (typeof pre[evt] === 'undefined') {
pre[evt] = 0
}
pre[evt] += evtObj[evt].length
})
return pre

Situation

  • We have three files - page.html, sidebard.html, main.html

page.html

  • Head only has jQuery
  • Body has three divs with id timestamp, sidebar and main.

main.html content

Situation

  • HTML body is black.
  • Head only has jQuery

Assignment

  • Create 100 li under ul - numbered 1,2,3 to 100 using jQuery
  • if clicked on any li, that li will be removed using jQuery
[Unit]
Description=Elasticsearch
Documentation=http://www.elastic.co
Wants=network-online.target
After=network-online.target
[Service]
RuntimeDirectory=elasticsearch
Environment=ES_HOME=/usr/share/elasticsearch
Environment=ES_PATH_CONF=/etc/elasticsearch/elasticsearch.yml
@VarunBatraIT
VarunBatraIT / react_rails_redux.sh
Created October 7, 2017 17:33
Rails with React, Redux, ES6, Webpack, and Gulp
# Create rails app
gem install make_it_so
make_it_so rails <name>
rake db:create db:migrate db:test:prepare && rspec
# get NPM set up (make sure node is installed)
npm init
npm install --save babel-loader gulp webpack gulp-webpack react redux react-redux
touch webpack.config.js
vim webpack.config.js

Please upload codes to github and share the url when you start the test.

Two different domains and Two Systems Client/Server.

  • Please consider that your backend is running at backendserver.com and html/css/jQuery OR angular/react app is running at frontendserver.com
  • Your server doesn't contain any codes of client. Both are mutually independent of each other. One laravel app is just a rest api, other app is nothing but simple forms built with angular/react or just jquery.

Three databases

  • information_db will contain a table shops with columns shop_name, db_name & reqeusts like

|id|shop_name|db_name|requests|

Two different domains.

  • Please consider that your backend is running at backendserver.com and angular app is running at frontendserver.com

Three databases

  • information_db will contain a table shops with columns shop_name, db_name & reqeusts like
id shop_name db_name requests
1 Shop A shop_a 0
2 Shop B shop_b 0