Skip to content

Instantly share code, notes, and snippets.

View johanguse's full-sized avatar
🏠
Working from home

Johan Guse johanguse

🏠
Working from home
View GitHub Profile
@DavidKuennen
DavidKuennen / minimal-analytics-snippet.js
Last active June 9, 2024 19:08
Minimal Analytics Snippet
(function (context, trackingId, options) {
const history = context.history;
const doc = document;
const nav = navigator || {};
const storage = localStorage;
const encode = encodeURIComponent;
const pushState = history.pushState;
const typeException = 'exception';
const generateId = () => Math.random().toString(36);
const getId = () => {
@igorbenic
igorbenic / allowedBlocks.js
Last active July 20, 2020 21:39
How to enable Inner Blocks in your Gutenberg Block | https://ibenic.com/enable-inner-blocks-gutenberg
<InnerBlocks allowedBlocks={ [ 'core/image', 'core/paragraph' ] } />
@DreaMinder
DreaMinder / A Nuxt.js VPS production deployment.md
Last active July 13, 2024 13:46
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

@kevbost
kevbost / WSL Install Guide.md
Created January 25, 2018 19:21
WSL Install Guide Windows

Ubuntu

Windows Subsystem for Linux [Very Easy Installation]

  1. https://msdn.microsoft.com/commandline/wsl/install_guide
    • [Follow instructions carefully and remember your password]
    • [it will prompt for password]
    • [password will not appear while you type, just push enter when finished]
  2. Open "Bash on Ubuntu on Windows"
  3. Run the commands formatted as code separately
  • (they will take a while to complete)
@benmccallum
benmccallum / _Instructions.md
Last active July 25, 2021 03:35
nuxtjs, bootstrap-vue with custom bootstrap build

Important! This guide is out of date (circa 2017) and should no longer be used. For the latest advice, please refer to the BootstrapVue docs and their Nuxt.js module. https://bootstrap-vue.org/docs#nuxt-js

General setup:

  1. Install bootstrap as a dev dependency, and its dependencies (node-sass and sass-loader) npm install --save-dev bootstrap@4.0.0-beta.2 node-sass sass-loader
@benmccallum
benmccallum / ..Instructions
Last active February 28, 2020 09:00 — forked from benosman/.deployment
Hosting Nuxt on Azure App Service (iisnode) with custom Git based deployment (kudu)
Previously this gist had a series of files showing a working setup, but,
@burkeholland found a much easier way and demonstrates it here:
https://github.com/burkeholland/nuxt-appservice-windows
Essentially, you'll:
1. add a .deployment file to instruct kudu to run `npm install` for you,
2. leverage npm tasks' `postinstall` hook in package.json to trigger the full nuxt build,
3. add a server.js file in the root that `require`s the default server\index.js file that a nuxt app will already have
Step 3 will be noticed by kudu, which will:
@BroFox86
BroFox86 / macro.html
Last active December 19, 2022 16:14
[Responsive image] Pug/Nunjucks responsive image mixin/macro #responsive
{% macro respImg(
class,
srcset,
sizes,
src,
width = "",
height = "",
loading = "",
alt = ""
)%}
@marcosnakamine
marcosnakamine / index.php
Created August 17, 2017 18:19
WordPress - Menu with Bootstrap 4 Navbar
<?php
$menu_items = wp_get_nav_menu_items('Menu Principal'); // PEGA TODOS OS ITENS DO Menu Principal
$menu_mobile = array();
foreach ( $menu_items as $key => $value ) { // SEPARA OS ITENS EM SUBMENUS
if ( !is_array( $menu_mobile[$value->menu_item_parent] ) ) {
$menu_mobile[$value->menu_item_parent] = array();
}
array_push( $menu_mobile[$value->menu_item_parent], $value );
}
?>
@marcosnakamine
marcosnakamine / index.php
Last active July 4, 2018 19:44
WordPress - Really Simple CAPTCHA plugin with custom form
<?php
// https://br.wordpress.org/plugins/really-simple-captcha/
$captcha_instance = new ReallySimpleCaptcha();
$captcha_instance->bg = array( 255, 255, 255 );
$word = $captcha_instance->generate_random_word();
$prefix = mt_rand();
$img_captcha = $captcha_instance->generate_image( $prefix, $word );
if ( isset( $_POST['send'] ) && $_POST['send'] == 'ok' ) {
if ( $captcha_instance->check( $_POST['prefix'], $_POST['captcha'] ) ) {
@marcosnakamine
marcosnakamine / class.ys_mail.php
Last active November 18, 2023 06:57
WordPress - Send mail wp_mail with attachment
<?php
class YS_Mail {
public function YS_Mail() {}
public function enviar( $e ) {
$headers = "From: ".$e['from_name']." <".$e['to_mail']."> \n";
$headers .= "Reply-To:".$e['from_name']." <".$e['from_mail']."> \n";