Skip to content

Instantly share code, notes, and snippets.

Avatar

Adriano Monecchi monecchi

View GitHub Profile
@monecchi
monecchi / Image.tsx
Created Feb 26, 2021 — forked from TheThirdRace/Image.tsx
Integrate NextJs `next/image` with Chakra-UI styling
View Image.tsx
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 Aug 10, 2020 — forked from calvinh8/1.mongodb-aws-setup-guide.md
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled
View 1.mongodb-aws-setup-guide.md

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 Apr 15, 2020 — forked from jonlabelle/string-utils.js
Useful collection of JavaScript string utilities.
View string-utils.js
// 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 Apr 2, 2020 — 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)
View wordpress-add-custom-menu-meta-fields.php
<?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
View App.scss
@import '~bootstrap/scss/bootstrap.scss';
View App.scss
@import '~bootstrap/scss/bootstrap.scss';
View exportjson.js
// 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 Jan 30, 2020 — forked from shifatul-i/date-ago.pipe.ts
Angular — date ago pipe (minutes / hours / days / months / years ago)
View date-ago.pipe.ts
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 Dec 7, 2019 — forked from amboutwe/yoast_seo_title_change-variable.php
Change existing or add custom title or meta template variables
View yoast_seo_title_change-variable.php
<?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 Sep 17, 2019
WooCommerce New Order Email to different recipient based on customer's city
View mr_wc_new_order_email_recipient.php
/**
* 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