Skip to content

Instantly share code, notes, and snippets.

// Import required libraries
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <Hash.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include <EEPROM.h>
@wdmtech
wdmtech / remove-console-statements-in-vue.md
Last active September 19, 2019 01:25
Vue config for latest vue-cli-service to strip out/remove console statements in production environments

But the solution’s not beautiful 🙈

There’s a bug with uglify-es, which requires using the following in your package.json to force dependencies to use this version:

"resolutions": {
  "uglify-es": "3.3.9"
},
@wdmtech
wdmtech / trim-strings-in-laravel-model-on-save.md
Last active August 18, 2023 14:55
Trim all strings in a Laravel Model before they are saved
public static function boot() {
    parent::boot();

    // Trim all string attributes before they are saved
    static::saving(function($model){
        $attributes = collect($model->getAttributes())->map(function ($attribute) {
            if (is_string($attribute)) {
                return trim($attribute);
 }
@wdmtech
wdmtech / vue-event-handler-with-extra-parameters.md
Last active May 2, 2018 18:23
How to pass component data AND events to a vue method
<button @click="event => { handleClick(event, item) }">Click me</button>
@wdmtech
wdmtech / Docker - Crap Cleaner
Created April 4, 2018 17:53
How to remove all the crud Docker leaves behind
### To remove all containers
docker rm -f $(docker ps -aq)
### To remove all volumes
docker volume rm $(docker volume ls -q)
### To remove all images
docker rmi -f $(docker images -a -q)
### Combined above 3 commands
@wdmtech
wdmtech / wget-entire-website
Created February 1, 2018 00:31
Wget entire website
// https://lifehacker.com/5796188/convert-a-blog-to-a-static-website-with-wget-and-rsync
./wget -m -p -P ./ executive-carhire.co.uk
@wdmtech
wdmtech / index.js
Created July 24, 2017 11:19
Facebook SDK (Graph/REST API) integration as a Vue.js mixin
export let facebookSDK = {
mounted () {
let _this = this
this.$nextTick(() => {
window.fbAsyncInit = function () {
FB.init({
appId: 'XXX',
xfbml: true,
version: 'v2.6'
})

#Node - Running in Production This gist is based on the excellent post by @hacksparrow which is found at http://www.hacksparrow.com/running-express-js-in-production-mode.html. The main principle is that you want the application to detect that it is running on a production server and to use the production configuration. The way to do this is to set the NODE_ENV=production. To do this you need to do the following:

$ export NODE_ENV=production

But we have a little problem here. The NODE_ENV environment variable will be lost if the server restarts, so it is safer to put it in the .bash_profile file. That way the variable will set again every time the system reboots. You will find the file in your home directory. It's a hidden file, so you can't see it unless you do a ls -la. We will append the export command to the .bash_profile file.

@wdmtech
wdmtech / AnonymousComponent.vue
Last active January 25, 2017 16:17
A Vue 2.0 component template
<template>
<span>
</span>
</template>
<script>
import { mapState, mapActions } from 'vuex'
export default {
name: 'anonymous-component',
@wdmtech
wdmtech / AwesompleteComponent.vue
Created October 28, 2016 08:13
Awesomeplete (autocomplete) component for vue 2.0 (provided as-is)
<template>
<span>
<input ref="autocomplete"
v-model="model"
class="input awesomeplete"
:placeholder="placeholder"
:class="classes"
@keyup="typing"
type="text"
title