Skip to content

Instantly share code, notes, and snippets.

Avatar

Franco Bouly rayfranco

View GitHub Profile
View router-snippet.js
router.beforeEach((to, from, next) => {
const requiresAuth = to.matched.some(record => {
return record.meta.requiresAuth
})
if (requiresAuth && !store.$data.isRegistered) {
next('/login')
} else {
next()
}
})
@rayfranco
rayfranco / checkStatus.js
Created Jun 21, 2018
Check for status code change periodically. Designed to be pasted in Chrome Dev Tools to bypass any CORS issues.
View checkStatus.js
function check (DELAY_MINUTE = 1, RESPONSE_CODE = 200) {
var req = new XMLHttpRequest()
req.addEventListener('load', onLoad)
function open () {
req.open('HEAD', location.href, true)
req.send()
}
function onLoad () {
req.status === RESPONSE_CODE ? notify() : setTimeout(open, DELAY_MINUTE * 60 * 1000)
}
@rayfranco
rayfranco / nuxt.config.js
Created Jun 1, 2018
Remove hash from filenames in Nuxt
View nuxt.config.js
module.exports = {
build: {
// Remove hash from build files
filenames: {
css: 'common.css',
manifest: 'manifest.js',
vendor: 'common.js',
app: 'app.js',
chunk: '[name].js'
@rayfranco
rayfranco / SomeComponent.js
Created Mar 6, 2018
Autoload Vue components folder
View SomeComponent.js
import SubfolderComponents from './subfolder'
export default {
components: {
// This will add all components in subfolder
...SubfolderComponents
}
}
View camelToKebab.js
module.exports = (string) => {
return string.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
}
@rayfranco
rayfranco / README.md
Last active May 5, 2020
Inline SVG with Nuxt
View README.md

Inline SVG with Nuxt

I was looking for a SSR and scoped styles ready solution to implement inline SVG with Nuxt

You need svg-inline-loader and xmldom to be installed.

@rayfranco
rayfranco / common-characters.txt
Created Jan 31, 2018
Common characters to be used with Google Fonts (FR)
View common-characters.txt
azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN<>,?!;.:/=+*$€£1234567890-_@#&'""`%()[]<>éèêçàùÉÈÊÇÀÙ
@rayfranco
rayfranco / .htaccess
Created Jan 25, 2018 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
View .htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
View keybase.md

Keybase proof

I hereby claim:

  • I am rayfranco on github.
  • I am rayfranco (https://keybase.io/rayfranco) on keybase.
  • I have a public key ASBwJPA-nwT-9R65pbQGalDUaGvb_axj4DaN58MQbTVSVwo

To claim this, I am signing this object:

View repulsion.js
var cushion = .5;
var length = 50;
var dx = point.x - mouse.x;
var dy = point.y - mouse.y;
var da = Math.sqrt(dx * dx + dy * dy);
// Tend à ramener la distance entre les segments à length
var ox = dx / da * length - dx;
var oy = dy / da * length - dy;
You can’t perform that action at this time.