Skip to content

Instantly share code, notes, and snippets.

View unr's full-sized avatar
💩
refactoring something...

Paul Morrison unr

💩
refactoring something...
View GitHub Profile
@unr
unr / testing_component.js
Created March 20, 2017 15:48
Spoofing Global Dependancy
// import and set up your test spoof.
import Vue from 'vue';
import VueRouter from 'VueRouter';
import routes from './routes';
// Set up your spoofed VueJs App? Basically mock app for test.
Vue.use(VueRouter);
const router = new VueRouter({
mode: 'history',
routes,
@unr
unr / main.js
Created March 21, 2017 15:01
Simplistic Axios in VueJs Example
const axiosconfig = {
baseurl: 'https://site.com/api/',
timeout: 30000,
};
import Vue from 'vue';
import axios from 'axios';
// Setting up Axios on Vue Instance, for use via this.$axios
Vue.prototype.$axios = axios.create(axiosConfig);
@unr
unr / app.vue
Created March 31, 2017 18:13
Basic 'how to show modal component' vue 2.0 example
<template>
<div id='app'>
<component :is="currentModal" :modal-data="extraData" v-if="showModal"></component>
</div>
</template>
<script>
import LoginModal from './LoginModal';
import LogoutModal from './LogoutModal';
@unr
unr / Track.js
Created May 1, 2017 14:40
Example of SPA Tracking file.
import _ from 'lodash';
import Vue from 'vue';
const Tracking = {
fbqActive: false,
deposit(notificationID, deposit) {
this.ecommerce(notificationID, deposit);
this.fbq('Deposit', { value: deposit.revenue, currency: 'USD' });
this.adwordConversion({
google_conversion_label: 'someconversionlabel',
@unr
unr / app.js
Created May 10, 2017 18:18
Worlds most simple Vue Plugin for Lodash
import Vue from 'vue';
import VueLodash from './vue-lodash.js';
Vue.use(VueLodash);
// On components, you'll now have access to
this._.filter();
@unr
unr / preview.vue
Last active April 10, 2018 14:25
.vue route for /preview
<template>
<div>loading preview...</div>
</template>
<script>
import prismic from 'prismic-javascript';
import LinkResolver from '~/functions/LinkResolver';
export default {
@unr
unr / PrismicApi.js
Last active August 11, 2018 20:02
Bare minimum example of Prismic API exposed as a Nuxt.js plugin
/**
* Prismic API
* Creates a prismic api instance on the app, for use in asyncData for loading content.
*/
import Vue from 'vue';
import prismic from 'prismic-javascript';
export default ({ app, env, error }) => {
const PrismicApi = {
// use this to access singular api instance in app
@unr
unr / AppLayout.js
Created October 16, 2018 21:12
Bare Minimum Laravel Echo in Nuxt.JS example.
// In my global app layout, once my app is mounted and ready to listen...
import { mapActions, mapGetters } from 'vuex';
const Layout = {
mounted() {
// set up pusher listeners
this.connectToPublicChannel();
this.$watch('authenticated', (auth) => {
if (auth) this.connectToUserChannel();
@unr
unr / vscode-settings.json
Created January 3, 2019 21:30
Example of unr's vetur-focused vim-setup in vscode.
{
// editor settings
"editor.formatOnSave": true,
"editor.renderWhitespace": "all",
"editor.fontSize": 14,
"editor.fontWeight": "500",
"editor.lineHeight": 28,
"editor.letterSpacing": 0,
"editor.fontFamily": "Hack",
"editor.insertSpaces": false,
@unr
unr / nginx.local.dev
Created February 27, 2019 18:09
Example Nginx file for a Laravel/Nuxt php server locally. Production runs something similar, but more complex with load balancers.
server {
listen 80;
server_name site.com www.site.com *.site.com;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl http2;
server_name site.com www.site.com *.site.com;
root /;