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 / settings.json
Created April 12, 2022 17:51
My current vscode settings
{
// editor settings
"editor.formatOnSave": true,
"editor.renderWhitespace": "all",
// my old fav
// "editor.fontFamily": "Hack",
// "editor.fontWeight": "500",
// Fira, omg that @ looks HORRID
@unr
unr / pusher.client.js
Created September 22, 2019 23:48
WIP Version of a custom Pusher Plugin for Nuxt.js - This is being used with a Laravel/ backend, where we have now replaced echo.
// plugins/pusher.client.js
// Browser only, create a new instance of pusher on load
// Accessible via this.$pusher
import Pusher from 'pusher-js';
export default ({ env, store }, inject) => {
// we need withCredentials for our CORS setup
Pusher.Runtime.createXHR = () => {
var xhr = new XMLHttpRequest();
@unr
unr / Buefy.js
Last active April 5, 2019 17:35
Jamming buefy into nuxt, the custom way without a module. Personally I found nuxt-buefy module to be useless, and just implemented buefy directly into my own nuxt app.
/**
* Integrates Buefy / Bulma CSS Components
* https://buefy.github.io/documentation/start
*/
import Vue from 'vue';
// Adds specific buefy components, matching to their name in docs
import Autocomplete from 'buefy/dist/components/autocomplete';
import Checkbox from 'buefy/dist/components/checkbox';
@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 /;
@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 / 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 / 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 / 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 / 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 / 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',