Skip to content

Instantly share code, notes, and snippets.

Hossam Mourad hos4m

Block or report user

Report or block hos4m

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hos4m
hos4m / 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
@hos4m
hos4m / 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);
@hos4m
hos4m / 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');
You can’t perform that action at this time.