Skip to content

Instantly share code, notes, and snippets.

View celsobessa's full-sized avatar

Celso Bessa celsobessa

View GitHub Profile
@celsobessa
celsobessa / shortcodes-in-custom-fields.php
Last active May 15, 2018 19:50
Usando shortcodes WordPress em campos customizados (WordPress shortcodes in custom fields)
// opção 1: função do_shortcode
// veja https://developer.wordpress.org/reference/functions/do_shortcode/
echo do_shortcode( $content, false );
// opção 2: o filtro the_content
// veja https://developer.wordpress.org/reference/hooks/the_content/
echo apply_filters('the_content', $content);
// pega um campo customizado em post e passa para do_shortcode
// veja https://developer.wordpress.org/reference/functions/get_post_meta/
@celsobessa
celsobessa / wordpress_export-post-data.php
Created July 16, 2018 04:08 — forked from robinnorth/wordpress_export-post-data.php
WordPress: Simple, configurable script to export post data to a CSV file
<?php
/**
* Export WordPress post data to CSV
* Based on <http://stackoverflow.com/a/3474698> and <http://ran.ge/2009/10/27/howto-create-stream-csv-php/>
*/
/**
*********************************************************************
* Configuration
*********************************************************************
@celsobessa
celsobessa / check-hooked-actions-filters.php
Last active February 21, 2019 14:43
Helper functions for developing and debugging WordPress plugins and themes
/**
* Prints all actions and filters hooked to a given hook.
*
* Prints all actions and filters hooked to a given hook.
* Inspired by answers in this WordPress Stackexchange question: https://wordpress.stackexchange.com/questions/17394/how-to-know-what-functions-are-hooked-to-an-action-filter
*/
function what_is_hooked(){
$hook_name = current_filter();
global $wp_filter;
@celsobessa
celsobessa / regexCheatsheet.js
Created January 15, 2019 17:53 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@celsobessa
celsobessa / .gitignore
Last active June 18, 2019 23:02 — forked from salcode/.gitignore
a fork of salcode .gitignore file for a general web project - Bare Minimum Git
# -----------------------------------------------------------------
# .gitignore
# Bare Minimum Git
# http://ironco.de/bare-minimum-git/
# ver 20181206
#
# From the root of your project run
# curl -O https://gist.githubusercontent.com/celsobessa/67e02d08bf89ada501e7ea8531cc0624/raw/a6a4ff4cd71112a566ed893846dd4ab8d14035c0/.gitignore
# to download this file
#
@celsobessa
celsobessa / isEmpty.js
Last active May 29, 2019 15:50
isEmpty, a javascript helper for checking if objects are empty.
// check all properites in a object as explained by Viktor Borisov on
// https://firstclassjs.com/check-if-object-is-empty-in-javascript/
function isEmpty(obj) {
for(var prop in obj) {
if(obj.hasOwnProperty(prop)) return false;
}
return true;
}
// use Examples
@celsobessa
celsobessa / parseUri.1.2.2.js
Created June 4, 2019 21:31
parseUri 1.2.2 by Steven Levithan
// parseUri 1.2.2
// (c) Steven Levithan <stevenlevithan.com>
// MIT License
function parseUri (str) {
var o = parseUri.options,
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
uri = {},
i = 14;
@celsobessa
celsobessa / sleep-es6.js
Created June 14, 2019 18:30
sleep() equivalent for vanilla Javascript using ES6 features
// sleep() equivalent for vanilla Javascript using ES6 features
// created by Dan Dascalescu
// see https://stackoverflow.com/questions/951021/what-is-the-javascript-version-of-sleep/39914235#39914235
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
async function demo() {
console.log('Taking a break...');
@celsobessa
celsobessa / shrinkpdf.sh
Created July 19, 2019 18:55 — forked from cbessadejusticia/shrinkpdf.sh
shrinkpdf.sh script by Alfred Klomp for optimizing (shrinking) PDF files using Ghostscript
#!/bin/sh
# http://www.alfredklomp.com/programming/shrinkpdf
# Licensed under the 3-clause BSD license:
#
# Copyright (c) 2014, Alfred Klomp
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
@celsobessa
celsobessa / multiple_ssh_setting.md
Created November 2, 2019 23:40 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"