Skip to content

Instantly share code, notes, and snippets.

View ahakem's full-sized avatar
👋
hi there

Ahmed Hakim ahakem

👋
hi there
View GitHub Profile
// all Countries sorted by Name
const countries = [
{ code: 'AF', label: 'Afghanistan', phone: '93' },
{ code: 'AL', label: 'Albania', phone: '355' },
{ code: 'DZ', label: 'Algeria', phone: '213' },
{ code: 'AX', label: 'Alland Islands', phone: '358' },
{ code: 'AS', label: 'American Samoa', phone: '1-684' },
{ code: 'AD', label: 'Andorra', phone: '376' },
{ code: 'AO', label: 'Angola', phone: '244' },
{ code: 'AI', label: 'Anguilla', phone: '1-264' },
function same(arr1, arr2){
if(arr1.length !== arr2.length){
return false;
}
let frequencyCounter1 = {}
let frequencyCounter2 = {}
for(let val of arr1){
frequencyCounter1[val] = (frequencyCounter1[val] || 0) + 1
}
for(let val of arr2){
@ahakem
ahakem / charCount.js
Last active December 22, 2019 22:07
Write a function which takes in a string and returns counts of each character in the string.
const string = "My Name is Ahmeeeeeed Hakim Elkholy"
const charCount = (str) => {
let obj = {};
let lowerString = str.toLowerCase();
[...lowerString].forEach(c => {
obj.hasOwnProperty(c) ? obj[c] ++ : c == " " ? null: obj[c] =1;
})
return obj
}
@ahakem
ahakem / icon
Last active July 14, 2019 08:10
how to use svg file in a page and change fill in css
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">
<!-- use symbol instead of defs and g,
must add viewBox on symbol just copy yhe viewbox from the svg tag itself
must add id on symbol
-->
<symbol id="location" viewBox="0 0 430.114 430.114">
// implement namespacing
var string = 'Enterprise.Company.Department.Team';
// output
/*
{
Enterpirse: {
Company: {
Department: {
Team: {}
const nums = [5, 0, 1,5, 11, 2, 5, 6,11, 4];
const nums2 = [5, 0, 1,5, 11, 2, 5, 6,11, 4];
let result = [];
function getUnique(arr){
let num = arr.pop();
if(result.indexOf(num) <= -1){
result.push(num);
}
if(arr.length > 1){
@ahakem
ahakem / biggest.js
Last active December 21, 2019 18:51
get bigest and smaller number
arr=[3,434,4,44,11]
Math.max(..arr)
var num = [5, 0, 1,5, 11, 2, 5, 6,11, 4];
let result = [];
function duplicateNum(arr){
let num = arr.pop();
if(arr.indexOf(num) > -1 && result.indexOf(num) <= -1 ){
result.push(num);
}
if(arr.length > 1){
duplicateNum(nums);
}