Skip to content

Instantly share code, notes, and snippets.

View iamgraeme's full-sized avatar

Graeme Houston iamgraeme

View GitHub Profile
@iamgraeme
iamgraeme / withNoBundleCompression.js
Created February 16, 2025 12:34 — forked from mrousavy/withNoBundleCompression.js
Expo Config Plugin to disable JS bundle compression for faster app startup
const {withAppBuildGradle} = require('@expo/config-plugins')
/**
* A Config Plugin to disable bundle compression in Android build.gradle.
* This makes the Android app start faster - in our tests by 400ms!
* @param {import('@expo/config-plugins').ConfigPlugin} config
* @returns {import('@expo/config-plugins').ConfigPlugin}
*/
module.exports = function withNoBundleCompression(config) {
return withAppBuildGradle(config, androidConfig => {
function render(model){
let current_state_name = model.active_states[0].name;
return $("h1",
{style: {color: "darkBlue"}},
`The current state is: ${current_state_name}`);
}
@iamgraeme
iamgraeme / SketchSystems.spec
Created November 16, 2023 09:30
White Label Loyalty
White Label Loyalty
Rewards Service
Random Event -> Ignore Event
WLL User Joined Audience Event -> WLL User Joined Audience Event
WLL Send Email Event -> WLL Send Email Event
Bridge Service
WLL User Joined Audience Event
Fire subscribed webhooks -> Handle IA User Joined Audience Webhook
WLL Send Email Event
Fire subscribed webhooks -> Handle IA Send Email Webhook
@iamgraeme
iamgraeme / filterArray.js
Created January 18, 2021 10:13 — forked from jherax/arrayFilterFactory.1.ts
Filters an array of objects with multiple match-criteria.
/**
* Filters an array of objects using custom predicates.
*
* @param {Array} array: the array to filter
* @param {Object} filters: an object with the filter criteria
* @return {Array}
*/
function filterArray(array, filters) {
const filterKeys = Object.keys(filters);
return array.filter(item => {
@iamgraeme
iamgraeme / solutionDynamicRoutesNuxt.js
Created July 9, 2020 12:13
You need to import axios at the top of nuxt.config.js, then add this to genenerate
generate: {
routes: function () {
const products = api.get('products?per_page=100').then(res => {
return res.data.map(product => `/product/${product.slug}`)
})
const categories = api
.get('products/categories?per_page=100')
.then(res => {
return res.data.map(category => `/category/${category.slug}`)
@iamgraeme
iamgraeme / index.js
Created April 20, 2020 19:04
Add this to store/index.js
export const actions = {
nuxtServerInit({ dispatch }, { req }) {
if (process.server && process.static) return;
if (!req.headers.cookie) return;
const cookies = Cookie.parse(req.headers.cookie || "");
const token = cookies["access_token"] || "";
console.log(token);
if (token) return dispatch("users/attempt", token);
@iamgraeme
iamgraeme / AttributeSelector.vue
Created April 16, 2020 23:45
AttributeSelector
<template>
<div>
<div v-if="isLoading">
<Loader />
</div>
<div v-else>
<div>
<div>
{{filters}}
<div class="item__variations variation__table">
@iamgraeme
iamgraeme / single-product-variation.js
Created April 16, 2020 23:42
SingleProductVariations
import React from 'react'
export default class SingleProductVariations extends React.Component {
constructor (props) {
super(props)
this.state = {
attributes: [],
options: [],
filters: [],
@iamgraeme
iamgraeme / functions.php
Last active April 10, 2020 16:27
Add cors to wordopress REST API
function add_cors_http_header(){
header("Access-Control-Allow-Origin: *");
header('Access-Control-Allow-Methods: GET, POST, PATCH, PUT, DELETE, OPTIONS, READ');
header('Access-Control-Allow-Headers: Origin, Content-Type, X-Auth-Token,authorization,XMLHttpRequest, user-agent, accept');
header("Access-Control-Allow-Credentials: true");
if ( 'OPTIONS' == $_SERVER['REQUEST_METHOD'] ) {
status_header(200);
exit();
}
@iamgraeme
iamgraeme / sortarray.js
Created April 6, 2020 07:42
Sory By Day
const sorter = {
monday: 1,
tuesday: 2,
wednesday: 3,
thursday: 4,
friday: 5,
saturday: 6,
sunday: 7,
};