Skip to content

Instantly share code, notes, and snippets.

View radarseven's full-sized avatar

Michael Reiner radarseven

  • York, PA
View GitHub Profile
@mohitmamoria
mohitmamoria / README.md
Last active June 25, 2024 11:07
Inertia.js Form Helper for Axios/API calls

Inertia.js ships with a fantastic form helper but it falls short when also using API/Axios calls in your project.

Here's a composable, built on top of the Inertia's form helper that hooks into it to replace the API calls with Axios.

To use, just replace useForm with useAPIForm.

const form = useAPIForm({
    title: '',
});
@reinink
reinink / app.js
Created November 2, 2018 12:56
Auto register Vue components
/**
* First we will load all of this project's JavaScript dependencies which
* includes Vue and other libraries. It is a great starting point when
* building robust, powerful web applications using Vue and Laravel.
*/
require('./bootstrap');
window.Vue = require('vue');
@Kruemelkatze
Kruemelkatze / ! Theming Ant Design with Sass and Webpack.md
Last active June 4, 2024 21:55
Theming Ant Design with Sass and Webpack

Theming Ant Design with Sass and Webpack

This is a solution on how to theme/customize Ant Design (which is written in Less) with Sass and webpack. Ant itself offers two solutions and a related article on theming, but these are only applicable if you use Less, the antd-init boilerplate or dva-cli.

What this solution offers:

  • use a single sass-file to customize (no duplicate variables for your project and Ant)
  • hot reload compatibility
  • no dependencies on outdated npm modules
  • easy integration with your existing webpack setup (webpack 3+ tested)
@Snugug
Snugug / README.md
Last active February 12, 2018 22:29
Progressively Enhanced Lazy Loading Images in 40 lines of code

Lazy Load Images in 40 Lines of Code

Behold! Intersection Observers at work!

Usage

First, update your source code to move your image sources in to data attributes.

@kohlmannj
kohlmannj / customDevServer.js
Created July 9, 2017 22:43
An example of using BrowserSync, webpack-dev-middleware, and webpack-hot-middleware together in a script that boots up a custom dev server
#! /usr/bin/env node
/* eslint-env node */
// Boot it up with:
// $ node customDevServer.js
// ...or:
// $ chmod +X customDevServer.js
// $ ./customDevServer.js
const webpack = require('webpack');
@jtulk
jtulk / package.json
Created March 29, 2017 15:37
Configuration for Babel-Loader Error When Specifying --env
{
"scripts": {
"build:prod": "webpack --env=prod --colors --profile --json > prod.stats.json",
"build:staging": "webpack --env=dev --colors --profile --json > staging.stats.json",
"start": "webpack-dev-server --env=dev --open --watch --progress",
}
}
@zcaceres
zcaceres / Revealing-Module-Pattern.md
Last active June 18, 2024 00:44
Using the Revealing Module Pattern in Javascript

The Revealing Module Pattern in Javascript

Zach Caceres

Javascript does not have the typical 'private' and 'public' specifiers of more traditional object oriented languages like C# or Java. However, you can achieve the same effect through the clever application of Javascript's function-level scoping. The Revealing Module pattern is a design pattern for Javascript applications that elegantly solves this problem.

The central principle of the Revealing Module pattern is that all functionality and variables should be hidden unless deliberately exposed.

Let's imagine we have a music application where a musicPlayer.js file handles much of our user's experience. We need to access some methods, but shouldn't be able to mess with other methods or variables.

Using Function Scope to Create Public and Private Methods

@martinherweg
martinherweg / browserSync.js
Last active May 29, 2021 08:07
Webpack + BrowserSync + HMR
/**
|--------------------------------------------------------------------------
| gulp browser-sync
|--------------------------------------------------------------------------
*
* Browser Sync
* @description Refresh the Brwoser after File Change.
* Combined with webpack for HMR or Content Reload
*
* @package generator-mh-boilerplate
# Install the hostsupdater:
# vagrant plugin install vagrant-hostsupdater
# Place the following code into $HOMESTEAD/scripts/homestead.rb
# I placed it somewhere near end of the file
# Add the aliases to the host machine
if Vagrant.has_plugin?('vagrant-hostsupdater')
aliases = Array.new
settings["sites"].each do |site|
@nickbasile
nickbasile / Component.vue
Last active July 30, 2021 02:40
How to use a namespaced action in a Vue.js component
<template>
<div>
<button @click="increment">Increment</button>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default{
methods: {