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 / get-users-first-last-name-wordpress.php
Created December 1, 2016 23:28 — forked from kellenmace/get-users-first-last-name-wordpress.php
Get User's First and Last Name in WordPress
<?php
/**
* Get user's first and last name, else just their first name, else their
* display name. Defalts to the current user if $user_id is not provided.
*
* @param mixed $user_id The user ID or object. Default is current user.
* @return string The user's name.
*/
function km_get_users_name( $user_id = null ) {
@monecchi
monecchi / plugin.php
Created September 6, 2018 23:29 — forked from igorbenic/plugin.php
Show a WordPress Post in a Modal - Article on Ibenic.com
<?php
/**
* Plugin Name: IBenic Bootstrap Modal
* Plugin URI: http://www.ibenic.com/show-a-wordpress-post-in-a-modal/
* Description: Show an article in a modal on the same page.
* Version: 1.0
* Author: Igor benić
* Author URI: http://www.ibenic.com
* License: GPL2
*
@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) {