Skip to content

Instantly share code, notes, and snippets.

@gaupoit
gaupoit / webpack.prod.js
Created February 23, 2019 09:10
Webpack production file
const merge = require('webpack-merge');
const common = require('./webpack.common');
const TerserPlugin = require('terser-webpack-plugin');
module.exports = merge(common, {
mode: 'production',
optimization: {
minimizer: [
new TerserPlugin()
],
@gaupoit
gaupoit / webpack.dev.js
Last active February 23, 2019 13:57
Webpack development configuration
const merge = require('webpack-merge');
const common = require('./webpack.common');
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-source-map'
});
@gaupoit
gaupoit / webpack.common.js
Last active February 23, 2019 10:49
Webpack common configuration
const path = require('path');
const { VueLoaderPlugin } = require('vue-loader');
const output = path.join(__dirname, '../admin/js/dist');
module.exports = {
mode: 'development',
entry: {
'gists-snippet-bundle': './src/index.js'
},
@gaupoit
gaupoit / hello-vue.js
Created January 31, 2019 08:13
hello_component.js
//Define a new component called hello-vue
Vue.component('hello-vue', {
template: '<div><h3>Hello Vue.js</h3></div>'
});
@gaupoit
gaupoit / hello_vue.js
Last active February 23, 2019 05:52
Hello Vue
<div id="app">
<p>{{ greeting }}</p>
<input v-model="name">
</div>
new Vue({
el: '#app',
data: {
greeting: 'Hello,',
name: 'PDA',
@gaupoit
gaupoit / hook_before_sending_file.php
Created September 27, 2018 13:33
PDA_HOOK_BEFORE_SENDING_FILE
<?php
function handle_pda_before_sending_file_hook( $server_data, $link_data ) {
//Write code to handle data here
}
add_action( 'PDA_HOOK_BEFORE_SENDING_FILE', 'handle_pda_before_sending_file_hook', 10, 2 );
?>
@gaupoit
gaupoit / protect_wp_file.php
Last active September 28, 2018 03:24
How to protect WordPress attachment's file with Prevent Direct Access service
<?php
if ( class_exists( 'PDA_Private_Link_Services' ) ) {
//669 is attachment's id.
$result = PDA_Private_Link_Services::protect_file( 669 );
if ( is_wp_error( $result ) ) {
echo $result->get_error_message();
}
}
@gaupoit
gaupoit / create_private_link.php
Last active August 29, 2018 06:34
How to create a private link with Prevent direct accecs WordPress Plugin
@gaupoit
gaupoit / fast_img.php
Last active August 12, 2018 10:16
Convert img tag into fast-img tag in the post's content or Woocommerce product's image
<?php
add_filter('the_content', 'pda_convert_img_to_fast_img', 10 );
/**
* Convert img tag to fast-img tag in the post's content
* @param $content The post's content
*
* @return mixed The massage content
*/
@gaupoit
gaupoit / config.yml
Created August 10, 2018 07:35
Build 3rd-party library for AWS Lambda function on CircleCI?
version: 2
jobs:
build:
docker:
- image: circleci/node:8.10
working_directory: ~/lambda_func
steps:
- checkout