This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function isPrimeNumber(n) { | |
for (var i = 2; i < n; i++) { // i will always be less than the parameter so the condition below will never allow parameter to be divisible by itself ex. (7 % 7 = 0) which would return true | |
if (n % i === 0) return false // when parameter is divisible by i, it's not a prime number so return false | |
} | |
return n > 1 // otherwise it's a prime number so return true (it also must be greater than 1, reason for the n > 1 instead of true) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove all subdirs/files except latest 5 (starting from the 6th here) | |
rm -r `ls -t | tail -n +6` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
router.beforeEach((to, from, next) => { | |
if (to.matched.some(record => record.meta.requiresAuth)) { | |
// this route requires auth, check if logged in if not, redirect to login page. | |
const isAuthenticated = false // TODO implement real auth check | |
if (!isAuthenticated) { | |
next({ path: '/login', query: { redirect: to.fullPath } }) | |
} else { | |
next() | |
} | |
} else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import VueRouter from 'vue-router' | |
export default new VueRouter({ | |
scrollBehavior(to, from, savedPosition) { | |
if (to.hash) { | |
return { selector: to.hash } | |
} | |
return savedPosition || { x: 0, y: 0 } | |
} | |
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const reverseObjIntoArray = obj => Object.keys(obj).sort().reverse().map(key=> ({ key, ...obj[key] })) | |
reverseObjIntoArray({ | |
124: { | |
a: 'foo', | |
b: 'bar' | |
}, | |
119: { | |
a: 'foo', | |
b: 'bart' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Saving you for future ref --> | |
<img class="aligncenter size-full wp-image-33949" src="https://maxcdn.icons8.com/app/uploads/2018/05/loading-animations-preloader-gifs-ui-ux-effects-18.gif" alt="" width="400" height="300"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:root { | |
--ease-in-quad: cubic-bezier(0.55, 0.085, 0.68, 0.53); | |
--ease-in-cubic: cubic-bezier(0.55, 0.055, 0.675, 0.19); | |
--ease-in-quart: cubic-bezier(0.895, 0.03, 0.685, 0.22); | |
--ease-in-quint: cubic-bezier(0.755, 0.05, 0.855, 0.06); | |
--ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035); | |
--ease-in-circ: cubic-bezier(0.6, 0.04, 0.98, 0.335); | |
--ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94); | |
--ease-out-cubic: cubic-bezier(0.215, 0.61, 0.355, 1); | |
--ease-out-quart: cubic-bezier(0.165, 0.84, 0.44, 1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default () => { | |
const styleEl = document.createElement('style') | |
document.head.appendChild(styleEl) | |
// Inject outline preventing styles only for non-keyboard users | |
document.addEventListener('mousedown', function () { | |
styleEl.innerHTML = 'a,a:focus,button,button:focus,input,input:focus,textarea,textarea:focus,div:focus {outline:none}' | |
}) | |
document.addEventListener('keydown', function () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin emoji-icon($color: var(--black), $size: 1rem) { | |
font-size: $size; | |
color: transparent; | |
text-shadow: 0 0 $color; | |
} | |
@mixin emoji-icon-stroke($color: var(--black), $fill: var(--white)) { | |
text-shadow: 0 0 $fill, | |
-1px -1px 0 $color, | |
1px -1px 0 $color, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const randStr = Math.random().toString(36).substr(2, 5) | |
export default `https://api.adorable.io/avatars/40/${randStr}@adorable` |