Skip to content

Instantly share code, notes, and snippets.

View celsofabri's full-sized avatar
👾
The truth is dubious

Celso Fabri Junior celsofabri

👾
The truth is dubious
View GitHub Profile
@celsofabri
celsofabri / chrome-no-cors
Created December 21, 2021 12:53
Open chrome without CORS
open -n -a /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --user-data-dir="/tmp/chrome_dev_test" --disable-web-security
@celsofabri
celsofabri / prettier-preferences
Created September 23, 2020 20:46
Preferences Prettier Sublime
{
"auto_format_on_save": true,
"auto_format_on_save_excludes": [
"/node_modules/",
"*.json",
"*.md",
"*.html"
],
"prettier_options": {
@celsofabri
celsofabri / context.js
Created September 16, 2020 13:19
Creating a context layer in React App
import React, { createContext, useState } from 'react';
import initialValues from './initial';
const Context = createContext(initialValues);
const GlobalContext = ({ children }) => {
const [globalState, setGlobalState] = useState(initialValues);
return (
<Context.Provider value={{ globalState, setGlobalState }}>
@celsofabri
celsofabri / WP Title Limit
Last active July 24, 2020 20:09
Word title limit WordPRess
function limit_word_count($title) {
$len = 5; //change this to the number of words
if (str_word_count($title) > $len) {
$keys = array_keys(str_word_count($title, 2));
$title = substr($title, 0, $keys[$len]);
}
return $title;
}
add_filter('the_title', 'limit_word_count');
@celsofabri
celsofabri / no-comments.js
Created April 4, 2017 18:56
Remove all comments from GitHub Pull Request
// Sometimes it's necessary to do a bit of clean-up
Array.prototype.forEach.call(document.querySelectorAll('.js-comment-delete button'), function(el, i) {
el.removeAttribute('data-confirm');
el.click();
});
@celsofabri
celsofabri / loadFeed.js
Last active August 26, 2016 18:32
LoadFeed Instagram/Recruiterbox
var instagramUrl = 'https://api.instagram.com/v1/users/self/media/recent/?access_token=myToken&callback=?&limit=1&count=12';
var recruiterboxUrl = 'https://jsapi.recruiterbox.com/v1/openings?client_name=myAccountName&limit=5';
// Instagram Media Load
var loadFeed = function(url, callback) {
$.ajax({
url: url,
dataType: 'json',
success: function(response) {
@celsofabri
celsofabri / functions.php
Created July 26, 2016 02:54 — forked from cezarsmpio/functions.php
Wordpress - Get the post terms
<?php
/**
* Get the terms of post
* @param object $p The post
* @param string $class CSS Class
* @param string $separator
* @return string The terms
*/
function get_post_terms($p, $class = 'post-preview__cat', $separator = '') {
@celsofabri
celsofabri / add_body_class_wpmu.php
Last active November 6, 2017 01:08
Add Class Body Multisite / Adicionando Classe Body para Multisite
<?php
// Apply filter
add_filter('body_class', 'multisite_body_classes');
function multisite_body_classes($classes) {
$id = get_current_blog_id();
$slug = strtolower(str_replace(' ', '-', trim(get_bloginfo('name'))));
$classes[] = sanitize_title('site-'.$slug);
return $classes;
}
@celsofabri
celsofabri / loop-page.php
Created October 21, 2015 13:46
Loop de Página (Section) / Loop Page
<!-- Loop com ID -->
<?php $my_query = new WP_Query('page_id=87');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<div class="entry">
<?php the_content(); ?>
</div>
@celsofabri
celsofabri / loop-author.php
Created October 8, 2015 20:20
Author Loop WordPress / Looping de Autores WordPress
<?php
$args = get_users(array(
'blog_id' => 1,
'orderby' => 'nicename',
'role' => 'editor'
));
foreach ( $args as $user ) {
echo '<span>' . esc_html( $user->description ) . '</span>';