Skip to content

Instantly share code, notes, and snippets.

@samueleiche
samueleiche / Tracker.js
Created November 29, 2019 09:15
Experimental user action tracker
/**
* The tracker object's instance class.
*
* @param {Object} config
*/
class TrackerNode {
constructor(config) {
/**
* The unique ID of the tracker node.
@samueleiche
samueleiche / package.json
Last active February 17, 2020 16:01
Sass postcss config 2020
{
"name": "sass-postcss",
"version": "1.0.0",
"scripts": {
"dev": "npm run compile -- --watch",
"compile": "sass style.scss:build.css",
"build": "npm run compile && postcss -u autoprefixer cssnano -r --map=false build.css"
},
"browserslist": [
"> 5%",
@samueleiche
samueleiche / package.json
Last active December 7, 2019 15:30
Vue webpack config for Wordpress or any other custom project
{
"name": "vue-webpack-config",
"version": "0.0.0",
"private": true,
"eslintConfig": ".eslintrc.js",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack --watch",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules -p",
"clean:modules": "rm -rf ./node_modules"
},
@samueleiche
samueleiche / Portal.js
Last active December 6, 2019 20:30
Portal plugin for Vue.js using Vue observable.
/**
* A Portal Plugin for Vue.js, to render components
* outside of other components, anywhere in the document.
*
* @plugin
* @example
* Vue.use(PortalPlugin);
* {
* computed: {
* portalTarget() {
@samueleiche
samueleiche / BreakpointObserver.js
Last active December 6, 2019 20:32
Breakpoint observer plugin for Vue.js using Vue observable.
/**
* A media query matcher plugin for Vue.js, to listen to
* matching breakpoints.
*
* @plugin
* @example
* const breakpoints = { mdDevice: '(max-width: 959px)' };
* Vue.use(BreakpointObserverPlugin, breakpoints);
* {
* computed: {
@samueleiche
samueleiche / Store.js
Created December 6, 2019 20:35
Simple state management for Vue.js using Vue observable.
/**
* Simple state management for Vue.js.
*
* @plugin
* @example
* new Store({
* form: {
* state: {
* searchText: '',
* },
@samueleiche
samueleiche / msie.css
Last active December 6, 2019 20:37
Detect if Internet Explorer in CSS and JS.
// if IE10+
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
// IE styles...
}
@samueleiche
samueleiche / parse.js
Last active December 6, 2019 20:45
JS parse query string/serialize object - Supports arrays - Working example - https://codepen.io/Samuel87/pen/QWWZopj
/**
* Parses a serialized query string to an object
*
* @param {string} query - query string to parse
* @returns {Object}
* @example
* parse('a=b&c=d');
* // => { a: 'b', c: 'd' }
* @example
* parse('a[]=b&a[]=c');
@samueleiche
samueleiche / cloudSettings
Last active November 25, 2020 11:36
Visual Studio Code settings sync
{"lastUpload":"2020-11-25T11:36:55.420Z","extensionVersion":"v3.4.3"}
@samueleiche
samueleiche / .htaccess
Created March 31, 2020 21:27
Vue.js VueRouter .htaccess config for subdirectory
<IfModule mod_rewrite.c>
DirectoryIndex /vue/dist/index.html
RewriteEngine On
RewriteBase /vue/dist
RewriteRule ^vue/dist/index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /vue/dist/index.html [L]
</IfModule>