Skip to content

Instantly share code, notes, and snippets.

View itsabdessalam's full-sized avatar
🤔
Thinking

Abdessalam Benharira itsabdessalam

🤔
Thinking
View GitHub Profile
@itsabdessalam
itsabdessalam / copy.js
Last active September 29, 2020 00:09
Copy to clipboard
// if code snippet is inside input or textarea tags
function copy() {
var codeSnippet = document.querySelector("#code-snippet");
codeSnippet.select();
document.execCommand("copy");
}
document.querySelector("#copy").addEventListener("click", copy);
// if code snippet is inside pre or code tags
function copy() {
@itsabdessalam
itsabdessalam / development.yml
Created August 17, 2020 06:49
development.yml
name: Development workflow
on:
push:
branches:
- develop
jobs:
build:
runs-on: ubuntu-latest
name: Production workflow
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
name: Test workflow
on:
pull_request:
branches:
- master
- staging
jobs:
build:
@itsabdessalam
itsabdessalam / getDeviceType.js
Last active April 19, 2020 14:38
getDeviceType - Helper to retrieve current device type
/**
* Helper to retrieve current device type
*/
export const getDeviceType = () => {
const ua = navigator.userAgent,
// we could have had several if, a switch with cases, or an object containing keys and values
// by preference and to reduce the process we chose an array of objects containing the type of device and the test
types = [
{
type: "tablet",
git branch -m old new
git push origin :old
git push --set-upstream origin new
# alias
alias gmv='mv() { git branch -m $1 $2; git push origin :$1; git push --set-upstream origin $2; }; mv'
@itsabdessalam
itsabdessalam / getFormData.js
Last active February 18, 2020 07:24
getFormData - Helper to retrieve fields of a form as an object
/**
* Helper to retrieve fields of a form as an object
*/
export const getFormData = form => {
if (!form || form.tagName !== "FORM") {
return;
}
const { elements } = form;
const data = {};
@itsabdessalam
itsabdessalam / sass-7-1-pattern.txt
Created December 19, 2019 09:59
The 7-1 Sass Pattern
sass/
|
|– abstracts/
| |– _variables.scss # Sass Variables
| |– _functions.scss # Sass Functions
| |– _mixins.scss # Sass Mixins
| |– _placeholders.scss # Sass Placeholders
|
|– base/
| |– _reset.scss # Reset/normalize
@itsabdessalam
itsabdessalam / getTopWindow.js
Created December 17, 2019 07:27
getTopWindow - helper to retrieve the topmost window
/**
* Helper to retrieve the topmost window
*/
export const getTopWindow = () => {
let w = window;
if (window.top) w = window.top;
else
while (w.parent) {
w = w.parent;
}
@itsabdessalam
itsabdessalam / extensions.txt
Last active December 17, 2019 06:31
vscode config
code --install-extension anthonydiametrix.ACF-Snippet
code --install-extension bierner.markdown-preview-github-styles
code --install-extension bmewburn.vscode-intelephense-client
code --install-extension bungcip.better-toml
code --install-extension ChakrounAnas.turbo-console-log
code --install-extension christian-kohler.npm-intellisense
code --install-extension christian-kohler.path-intellisense
code --install-extension cjhowe7.laravel-blade
code --install-extension cmstead.jsrefactor
code --install-extension CoenraadS.bracket-pair-colorizer