Skip to content

Instantly share code, notes, and snippets.

Avatar

Hossam Mourad hossammourad

View GitHub Profile
View counties.json
{
"countries": {
"colombia": {
"name": "Colombia",
"code": "CO"
},
"egypt": {
"name": "Egypt",
"code": "EGY"
},
@hossammourad
hossammourad / vscode-eslint-autofix-keybinding
Created Mar 20, 2020
VSCode keybinding to auto-fix ESLint issues when the formatting code shortcut shift+alt+F is pressed
View vscode-eslint-autofix-keybinding
{
"key": "shift+alt+f",
"command": "editor.action.codeAction",
"args": {
"kind": "source.fixAll.eslint",
"apply": "first"
}
}
@hossammourad
hossammourad / generate-random-number.js
Last active Apr 2, 2019
Generate random number between two numbers
View generate-random-number.js
Math.floor(Math.random() * 100) + 1
// 1 -> start
// 100 -> end
@hossammourad
hossammourad / getBase64.js
Last active Mar 18, 2019
[Client-Side]: from file URL to Base64
View getBase64.js
const getBase64 = fileURL =>
new Promise(async resolve => {
const response = await fetch(fileURL);
const blob = await response.blob();
const reader = new FileReader();
reader.readAsDataURL(blob);
reader.onloadend = () => {
const base64data = reader.result;
resolve(base64data);
@hossammourad
hossammourad / formatDate.js
Last active Aug 23, 2018
Format date using moment and locale
View formatDate.js
import moment from 'moment';
export default ({ year, month, day }) => {
const locale = 'en-US';
const val = moment()
.year(year)
.month(month)
.date(day);
moment.locale(locale);
const formatter = moment.localeData().longDateFormat('L');