Skip to content

Instantly share code, notes, and snippets.

View monecchi's full-sized avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / Image.tsx
Created February 26, 2021 14:57
Integrate NextJs `next/image` with Chakra-UI styling
import { chakra, ThemingProps, useStyleConfig } from '@chakra-ui/react'
import NextImage, { ImageProps as NextImageProps } from 'next/image'
import { ReactElement } from 'react'
import { Sizes } from '../../theme/variables/image'
// TODO review props when NextJs is updated so we don't have to defined it here
/**
* ? Because NextJs typing is preventing auto-suggest for layout, width and height,
* ? we declare the styles differently in this component and will manage the switch
* ? to NextJs typings when calling NextJs `next/image` component
@monecchi
monecchi / 1.mongodb-aws-setup-guide.md
Created August 10, 2020 05:46 — forked from calvinh8/1.mongodb-aws-setup-guide.md
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled

MongoDB AWS EC2 Setup Guide

You can see my latest update in my blog here https://medium.com/@calvin.hsieh/steps-to-install-mongodb-on-aws-ec2-instance-62db66981218

Credits:

Big thanks to Elad Nava and Shane Rainville for writing the above articles that allow me to conduct this guide. If by all means that I violated original post's copyright, please contact me.

@monecchi
monecchi / string-utils.js
Created April 15, 2020 17:28 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
// String utils
//
// resources:
// -- mout, https://github.com/mout/mout/tree/master/src/string
/**
* "Safer" String.toLowerCase()
*/
function lowerCase(str) {
return str.toLowerCase();
@monecchi
monecchi / wordpress-add-custom-menu-meta-fields.php
Created April 2, 2020 00:34 — forked from helgatheviking/wordpress-add-custom-menu-meta-fields.php
Add an example custom meta field to WordPress menu and display text on front-end (Requires WP5.4)
<?php
/**
* Add custom fields to menu item
*
* This will allow us to play nicely with any other plugin that is adding the same hook
*
* @param int $item_id
* @params obj $item - the menu item
* @params array $args
@monecchi
monecchi / App.scss
Created February 17, 2020 16:07 — forked from igorbenic/App.scss
Headless WordPress: Logging with JWT | https://www.ibenic.com/headless-wordpress-logging-with-jwt
@import '~bootstrap/scss/bootstrap.scss';
@monecchi
monecchi / App.scss
Created February 17, 2020 16:07 — forked from igorbenic/App.scss
Headless WordPress: Logging with JWT | https://www.ibenic.com/headless-wordpress-logging-with-jwt
@import '~bootstrap/scss/bootstrap.scss';
// Includes functions for exporting active sheet or all sheets as JSON object (also Python object syntax compatible).
// Tweak the makePrettyJSON_ function to customize what kind of JSON to export.
var FORMAT_ONELINE = 'One-line';
var FORMAT_MULTILINE = 'Multi-line';
var FORMAT_PRETTY = 'Pretty';
var LANGUAGE_JS = 'JavaScript';
var LANGUAGE_PYTHON = 'Python';
@monecchi
monecchi / date-ago.pipe.ts
Created January 30, 2020 12:22 — forked from shifatul-i/date-ago.pipe.ts
Angular — date ago pipe (minutes / hours / days / months / years ago)
import {Pipe, PipeTransform} from '@angular/core';
@Pipe({
name: 'dateAgo',
pure: true
})
export class DateAgoPipe implements PipeTransform {
transform(value: any, args?: any): any {
if (value) {
@monecchi
monecchi / yoast_seo_title_change-variable.php
Created December 7, 2019 08:53 — forked from amboutwe/yoast_seo_title_change-variable.php
Change existing or add custom title or meta template variables
<?php
/********* DO NOT COPY THE PARTS ABOVE THIS LINE *********/
/* Remove Yoast SEO Change existing title or meta template variable
* Credit: Moshe Harush
* https://stackoverflow.com/questions/36281915/yoast-seo-how-to-create-custom-variables
* Last Tested: Unknown
*/
// define the wpseo_replacements callback
function filter_wpseo_replacements( $replacements ) {
@monecchi
monecchi / mr_wc_new_order_email_recipient.php
Last active March 6, 2023 04:43
WooCommerce New Order Email to different recipient based on customer's city
/**
* Add another email recipient for admin New Order emails if a shippable product is ordered for a specific city
*
* @param string $recipient a comma-separated string of email recipients (will turn into an array after this filter!)
* @param \WC_Order $order the order object for which the email is sent
* @return string $recipient the updated list of email recipients
*/
function mr_wc_conditional_email_recipient( $recipient, $order ) {
// Bail on WC settings pages since the order object isn't yet set yet
// Not sure why this is even a thing, but shikata ga nai