Skip to content

Instantly share code, notes, and snippets.

@enxoco
enxoco / binarySearch.js
Created May 23, 2022 23:41
An example of simple recursion based binary search in JavaScript
// Generate an array of x length
function generateArray(len) {
let arr = []
for (var i = 0; i < len; i++) {
arr.push(i)
}
return arr
}
/*
@enxoco
enxoco / FlipCards.functions.php
Last active October 15, 2021 18:18
Example of nesting components in FlyntWP. In this example, embedding Flip Cards in BlockWysiwyg component
<?php
namespace Flynt\Components\FlipCards;
use Flynt\FieldVariables;
function getACFLayout()
{
return [
'name' => 'flipCards',
@enxoco
enxoco / vue.config.js
Created November 16, 2020 18:21
A living reference for vue config options.
module.exports = {
filenameHashing: false, //Use app.js instead of app.26232462.js
configureWebpack: config => {
//Use custom names for output files. Leave [name] but replace appName
config.output.filename = 'js/appName.[name].js'
config.output.chunkFilename = 'js/appName.[name].js'
config.output.hotUpdateChunkFilename = 'js/area-research.[name].js'
},
chainWebpack: config => {
{% block content %}
<div class="d-flex flex-column flex-md-row align-items-center justify-contents-between p-3 px-md-4 mb-3 bg-white border-bottom shadow-sm sticky-top">
<img class="img-fluid img-logo" src="https://iowngf.org/wp-content/uploads/2020/08/IOWN-Logo-RGB.jpg" alt="IOWN Global Forum" />
<nav class="my-2 my-md-0 mr-md-3">
{% for item in menu.items %}
{% if item.children %}
<li class="nav-item dropdown">
{% if item.current %}
@enxoco
enxoco / timber-preview-fix.php
Last active September 25, 2020 19:16
A simple fix for Wordpress previews not working with Timber installed
<?php
//For some crazy reason Timber does not seem to support page/post previews out of the box!
//Adding this to controllers should resolve this issue.
//!Important if you are using Flynt or a similiar component based framework
//Or you are noticing that ACF fields are not updating in previews make sure that
//define( 'WP_POST_REVISIONS', 3 );
//is set in wp-config.php. WP Engine as this set to disabled by default
$context['post'] = new TimberPost();
@enxoco
enxoco / menu.css
Last active January 29, 2020 02:26
Add this css snippet somewhere.
@media (min-width: 1025px) {
ul#primary-menu {
display: flex;
align-items: center;
}
}
/* Update your main stylesheet. Should be style.css with this */
#site-navigation {
// Change grid-column from this
grid-column: 2/3;
var submitButton = document.getElementsByClassName('frm_final_submit')[0];
var addToCart = function() {
var appTypeCode = localStorage.getItem('appTypeCode');
// The rest of this function copied from
// https://gist.githubusercontent.com/mircian/709f93862edad5111e36b21c83c27b73/raw/2d5a1fa6cff6ceb684db397d3ad7bedc618344fc/woocommerce_simple_add_to_cart.js
if ( 'undefined' === typeof wc_add_to_cart_params ) {
// The add to cart params are not present.
return false;
@enxoco
enxoco / formAssemblyBallotMessage.js
Last active December 5, 2019 18:33
A simple bit of custom JavaScript to hide a FormAssembly form and show a custom message to the user when their ballot has been cast.
<script>
/*
* This script should be placed in Properties section of a form assembly form.
* It assumes that you have at least two visible text inputs. One named Ballot Status and one named Ballot Cast Message.
* For the script to work properly, Ballot Cast Message should NOT be a hidden field.
* The script will automatically hide it from the user but relies on a Title attribute which is not added to hidden fields by default.
*/
window.addEventListener('load', function () {
var ballotStatus = document.querySelector("input[title='Ballot Status']");
if (ballotStatus.value.toLowerCase() === 'cast') {// If ballot has been cast, hide form and show message.
@enxoco
enxoco / StoreController.js
Created September 27, 2019 16:18
This is the code that is responsible for rendering a store locator view. It uses Mapbox and Turf.js to calculate the distance of each store relative to the user and sort them based on the closest one. pickup-flow.js is the frontend code that runs in the browser while StoreController.js is the backend controller method that pulls a list of stores…
'use strict'
const Database = use('Database')
const Env = use('Env')
const stripe = require('stripe')(Env.get('STRIPE_SK'))
class StoreController {
async showStores({request, response, view}) {
const stores = await Database
.table('locations')

Keybase proof

I hereby claim:

  • I am enxoco on github.
  • I am enxo (https://keybase.io/enxo) on keybase.
  • I have a public key ASCvGX6Nnbelcbe4OHg7oFmsrx4x0GYgUcOVlbrxI6GHLAo

To claim this, I am signing this object: