Skip to content

Instantly share code, notes, and snippets.

View hossammourad's full-sized avatar

Hossam Mourad hossammourad

View GitHub Profile
file1
@hossammourad
hossammourad / file-one.js
Last active September 22, 2022 18:27
gist with 2 files
file1 content
{
"countries": {
"colombia": {
"name": "Colombia",
"code": "CO"
},
"egypt": {
"name": "Egypt",
"code": "EGY"
},
@hossammourad
hossammourad / vscode-eslint-autofix-keybinding
Created March 20, 2020 02:37
VSCode keybinding to auto-fix ESLint issues when the formatting code shortcut shift+alt+F is pressed
{
"key": "shift+alt+f",
"command": "editor.action.codeAction",
"args": {
"kind": "source.fixAll.eslint",
"apply": "first"
}
}
@hossammourad
hossammourad / generate-random-number.js
Last active April 2, 2019 11:04
Generate random number between two numbers
Math.floor(Math.random() * 100) + 1
// 1 -> start
// 100 -> end
@hossammourad
hossammourad / getBase64.js
Last active March 18, 2019 07:01
[Client-Side]: from file URL to Base64
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 August 23, 2018 19:34
Format date using moment and locale
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');