Skip to content

Instantly share code, notes, and snippets.

View rashid327's full-sized avatar

Rashid ALi rashid327

  • TekFocal
  • Lahore
View GitHub Profile
@rashid327
rashid327 / gist:57eeda357e8a38dcf375c34b68d20264
Created March 22, 2022 09:26
find specific word and their count in array object in javascript
const object1 = {
a: 'NO',
b: 'NO',
c: 'Yes',
d: 'NO',
};
//console.log(Object.values(object1));
function getWordCount(array) {
const person = [{
firstName: 'John',
lastName: 'Doe'
},
{
firstName: 'John',
lastName: 'Doe'
}];
var propertyValues = [];//Object.values(person[0]);
@rashid327
rashid327 / gist:f18e8f0c9e47bf4a8eeaee1ed5fe0c0b
Created September 8, 2020 06:35
Setting map bounds for multiple markers
function setMarkers(map) {
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < restaurants.length; i++) {
var restaurant = restaurants[i];
var layerposit = (restaurant[4] == 1 ? 999 : restaurant[3]);
var marker = new google.maps.Marker({
position: {
lat: restaurant[1],
Usage:
# Checkout an existing branch
$ git checkout <branch_name>
# Checkout and create a new branch with that name
$ git checkout -b <new_branch>
In Practice:
# Create a new branch
$ git branch <branch_name>
# List all remote or local branches
$ git branch -a
# Delete a branch
$ git branch -d <branch_name>
@rashid327
rashid327 / gist:85632e720ba7b414daa87b63be44b721
Created August 28, 2020 07:43
Git force pull to overwrite local files ( Git Pull )
git fetch --all
git reset --hard origin/master
git pull origin master
@rashid327
rashid327 / Round value in JavaScript
Created March 10, 2020 05:28
Round value in JavaScript upto 6 decimal places
var val = 21.877768666
Math.round(val * 1000000) / 1000000);
Output:
21.877769
@rashid327
rashid327 / JS forEash
Created February 26, 2020 07:01
JS forEash
<script>
var sum = 0;
var numbers = [91, 2, 4, 45, 65, 32, 49];
numbers.forEach(myFunction);
function myFunction(item) {
sum += item;
document.getElementById("demo").innerHTML = sum;
}
</script>
@rashid327
rashid327 / Array.prototype.forEach()
Created February 26, 2020 05:45
Array.prototype.forEach()
const array1 = ['a', 'b', 'c'];
array1.forEach(element => console.log(element));
// expected output: "a"
// expected output: "b"
// expected output: "c"
@rashid327
rashid327 / javaScript localStorage
Created February 18, 2020 13:34
javaScript localStorage
// set data on localstorage
localStorage.setItem("username", "admin");
// get data from localstorage
localStorage.getItem("username");