Skip to content

Instantly share code, notes, and snippets.

View nandomoreirame's full-sized avatar
🎧
Working from home

Fernando Moreira nandomoreirame

🎧
Working from home
View GitHub Profile
@nandomoreirame
nandomoreirame / android-commands.md
Last active April 7, 2023 23:54
Comandos basicos android, cordova e ionic :)

android

Instalar o apk no device android para testes

adb install -r platforms/android/build/outputs/apk/android-debug.apk

Abre o log do dispositivo android

adb logcat

Lista os adb divices rodando

@nandomoreirame
nandomoreirame / rest-api-contact-mail.php
Created August 19, 2019 02:07
WP REST API send contact mail
<?php
add_action('rest_api_init', function () {
register_rest_route( 'contact/v1', 'send', [
'methods' => 'POST',
'callback' => 'api_send_contact_form'
]);
});
function api_send_contact_form( $request ) {
@nandomoreirame
nandomoreirame / function.php
Last active January 1, 2023 04:47
WordPress REST API send email SMTP in with PHPMailer
<?php
function sendWithPhpMailer($subject, $body, $reply) {
require(ABSPATH . WPINC . '/class-phpmailer.php');
require(ABSPATH . WPINC . '/class-smtp.php');
// date_default_timezone_set( 'America/Sao_Paulo' );
$blogname = wp_strip_all_tags( trim( get_option( 'blogname' ) ) );
$smtpHost = wp_strip_all_tags( trim( get_option( 'smtp_host' ) ) );
@nandomoreirame
nandomoreirame / breakpoints.css
Last active September 28, 2021 00:09
media query breakpoints
/* Smartphones (portrait and landscape) ----------- */
@media only screen and (min-device-width: 320px) and (max-device-width: 480px) { /* Styles */ }
/* Smartphones (landscape) ----------- */
@media only screen and (min-width: 321px) { /* Styles */ }
/* Smartphones (portrait) ----------- */
@media only screen and (max-width: 320px) { /* Styles */ }
/* iPads (portrait and landscape) ----------- */
@nandomoreirame
nandomoreirame / .editorconfig
Last active August 4, 2021 20:31
my .editorconfig
# https://editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
@nandomoreirame
nandomoreirame / gpg-key.md
Last active August 1, 2021 19:53
Github verify commits

Keybase proof

I hereby claim:

  • I am nandomoreirame on github.
  • I am onandomoreira (https://keybase.io/onandomoreira) on keybase.
  • I have a public key ASCWboqGKY1Tl79c0VTsmn4LKZNn678UOOnOH9GJzUFaFAo

To claim this, I am signing this object:

@nandomoreirame
nandomoreirame / how-much-in-localstorage.js
Created April 5, 2021 16:41
how much is in localstorage
let _lsTotal = 0;
let _xLen;
let _x;
for (_x in localStorage) {
if (!localStorage.hasOwnProperty(_x)) {
continue;
}
_xLen = ((localStorage[_x].length + _x.length) * 2);
_lsTotal += _xLen;
@nandomoreirame
nandomoreirame / custom-fields.php
Created August 19, 2019 02:04
Add custom post meta to WordPress REST API
<?php
function get_custom_post_meta_cb($object, $field_name, $request) {
return get_post_meta( $object['id'], $field_name, true );
}
function get_custom_post_meta_cb_the_content($object, $field_name, $request) {
return apply_filters( 'the_content', get_post_meta( $object['id'], $field_name, true ) );
}
@nandomoreirame
nandomoreirame / metabox-page.php
Last active July 20, 2020 21:56
add custom metabox per page
<?php
function theme_metabox_per_page() {
global $pagenow;
if ( $pagenow == 'post.php' ) {
$page_id = ( $_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['post_ID'] ) ? $_POST['post_ID'] : $_GET['post'];
if ( $page_id ) {
$page_slug = get_post_field( 'post_name', $page_id );
@nandomoreirame
nandomoreirame / promise-timeout.js
Created March 31, 2020 20:46
Timeout with Promise for use async await
const timeout = ms => new Promise(resolve => setTimeout(resolve, ms));
const sleep = async (fn, ...args) => {
await timeout(3000);
return fn(...args);
};