Skip to content

Instantly share code, notes, and snippets.

View AhmedBHameed's full-sized avatar
💭
Searching for new challenge

Ahmed HAMEED AhmedBHameed

💭
Searching for new challenge
View GitHub Profile
@AhmedBHameed
AhmedBHameed / terminal-colors-branch.sh
Created February 3, 2024 14:59 — forked from danielalvarenga/terminal-colors-branch.sh
Show branch in terminal Ubuntu
# Add in ~/.bashrc or ~/.bash_profile
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
RED="\[\033[01;31m\]"
YELLOW="\[\033[01;33m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
NO_COLOR="\[\033[00m\]"
@AhmedBHameed
AhmedBHameed / download-file.js
Created January 30, 2022 15:11 — forked from javilobo8/download-file.js
Download files with AJAX (axios)
axios({
url: 'http://localhost:5000/static/example.pdf',
method: 'GET',
responseType: 'blob', // important
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'file.pdf');
document.body.appendChild(link);
@AhmedBHameed
AhmedBHameed / JS helper functions.md
Last active March 14, 2019 14:00
Helper function for JavaScript ES6

Those are ES6 helper functions

ArrayToObjects or ArrayToEntities

let arrayToObj = (array, keyField) => Object.assign({}, ...array.map( item => ({[item[keyField]]: item}) ));

let arrayOfObj = [
    {id: 10, name: "Ahmed", age: 29},
 {id: 11, name: "Mohameed", age: 36}

Font Face

A mixin for writing @font-face rules in SASS.

Usage

Create a font face rule. Embedded OpenType, WOFF2, WOFF, TrueType, and SVG files are automatically sourced.

@include font-face(Samplino, fonts/Samplino);