Skip to content

Instantly share code, notes, and snippets.

View chandanrjit's full-sized avatar
🕶️
At work

Chandan Kumar chandanrjit

🕶️
At work
View GitHub Profile
@chandanrjit
chandanrjit / docker-command
Created January 12, 2017 15:46
Docker Image for Nodejs application
Docker build -f Dockerfile -t "Reponame" .
//-f will look for the file nanme Dockerfile -- so we can keep any fileanme
// Check the Images build using --
Docker Images
//Now push the docker Image to your docker-hub repo
docker tag {ImangeID} {docker-account-name}/{Image-name}:{Version}
-------------------------------****************-------------------------------------
@chandanrjit
chandanrjit / forEach
Last active December 1, 2018 07:35
forEach vs for loop
let arrayforeach = [1, 2, 3]
console.log('--Loop using for loop--')
for (let i = 0; i < arrayforeach.length; i++) {
console.log(arrayforeach[i] * 2)
}
console.log('--Loop using forEach with anonymous function--')
arrayforeach.forEach(function (el) {
@chandanrjit
chandanrjit / map
Created December 1, 2018 07:31
map vs for loop with array
let cardNo = ['001', '002', '003']
// for loop and push each value to final array
let getFormattedCard = []
for (let i = 0; i < cardNo.length; i++) {
getFormattedCard.push(`Visa-${cardNo[i]}`);
}
console.log(getFormattedCard, 'for-loop-with-push')
// map with anonymous function
@chandanrjit
chandanrjit / filter
Created December 1, 2018 14:25
ES filter usage
// data
//for & if
//filter should return
let direction = ["South", "North", "East", "West", "NorthWest", "NorthEast", "SouthWest", "SouthEast"]
let filteredDirection = []
//
for (let i = 0; i < direction.length; i++) {
if (direction[i].match("West")) {
filteredDirection.push(direction[i])
@chandanrjit
chandanrjit / find
Created December 2, 2018 06:55
Array find helper method
let carsNo = ['001', '002', '003', '004']
let myCarNo;
console.log('--for loop')
for (let i = 0; i < carsNo.length; i++) {
if (carsNo[i] === "002") {
myCarNo = carsNo[i]
}
}
@chandanrjit
chandanrjit / some
Last active December 2, 2018 07:39
Array helper -Some
// lenght check of each element and return true if any one of them satisfy the conditions
let items = ['001', '00002', '0000003', '002']
let validatelength = false
console.log('---for loop')
for (let i = 0; i < items.length; i++) {
if (items[i].length > 4)
validatelength = true
}
console.log(validatelength, 'for loop')
@chandanrjit
chandanrjit / every
Created December 2, 2018 07:47
Array helper-every
// lenght check of each element and return true if all of them satisfy the conditions
let items = ['001', '00002', '0000003', '002']
let validatelength = false
console.log('---for loop')
for (let i = 0; i < items.length; i++) {
validatelength = items[i].length > 2
}
console.log(validatelength, 'for loop')
@chandanrjit
chandanrjit / reduce
Created December 2, 2018 08:52
Array helper-reduce
//get email id
let users = [{
userID: "1",
userEmail: "user1@email.com"
},
{
userID: "2",
userEmail: "user2@email.com"
},
{
@chandanrjit
chandanrjit / reduce-sum-example
Created December 2, 2018 11:39
Array helper -reduce
// Can implemented all helper using reduce
let number = [10, 20, 30]
let sum = 0;
for (let i = 0; i < number.length; i++) {
sum += number[i];
}
console.log(sum)
node {
// Check the input build no exits or not
stage('Check the Valid Build Number') { // for display purposes
def jenkins = Jenkins.getInstance()
def jobName = "Demo"
def job = jenkins.getItem(jobName)
def BuildNo = "${BUILD_NUMBER}"
println "Last successfull build: ${job.getLastSuccessfulBuild()}"
def allbuild = "${job.getBuilds().collect{ it.getNumber()}}"