Skip to content

Instantly share code, notes, and snippets.

View castroalves's full-sized avatar
🏠
Working from home

Cadu de Castro Alves castroalves

🏠
Working from home
View GitHub Profile
@castroalves
castroalves / linkedin-mass-unfollow.js
Created July 7, 2020 15:40
Linkedin Mass Unfollow
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.is-following') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
@castroalves
castroalves / pergaminho.php
Last active April 20, 2020 10:58
Solução do Pergaminho de Fasdal
<?php
/**
* Usage: run `php pergaminho.php` on Terminal
*
* @author Cadu de Castro Alves <https://github.com/castroalves>
*/
$encrypted_message = 'VNWRWJ BQJAXW YXBBDR BJWPDN ANJU. YANLRBJVXB MNUJ YJAJ ANBBDBLRCJA X NGNALRCX MN VXACXB N RWRLRJA J MNBCADRLJX CXCJU MN OJBMJU.';
$decrypted_message = 'FASDAL DE CU EH ROLA';
@castroalves
castroalves / acf-form-disable-post-content-settings.php
Created March 18, 2020 23:50
Disables tabs and media upload button in post content field. It also sets basic toolbar.
/**
* Disables tabs and media upload button in post content field
*
* @param $field
*
* @return mixed
*
* @author Cadu de Castro Alves <cadudecastroalves@gmail.com>
*/
function rpa_hub_disable_post_content_settings( $field ) {
@castroalves
castroalves / php-anonymous-function-in-arrays.php
Last active March 11, 2020 16:32
Small experiment using anonymous functions in arrays
<?php
$form = [
'action' => 'http://nextbike.com',
'target' => '_blank',
'method' => 'POST',
'fields' => [
['type' => 'text', 'name' => 'first_name', 'label' => 'First Name'],
['type' => 'text', 'name' => 'last_name', 'label' => 'Last Name'],
['type' => 'date', 'name' => 'birthday', 'label' => 'Birthday'],
/**
* Book CPT for testing purposes
*/
function cpt_book()
{
register_post_type(
'cpt_book',
array(
'labels' => array(
'name' => __('Books'),
@castroalves
castroalves / batches.json
Created November 1, 2019 14:05
Mailchimp API - Start a batch operation
{
"operations": [
{
"method": "DELETE",
"path": "lists/d8be282a42/members/0620517b07414ec8fd56ce1ed4ae3b72"
},
{
"method": "DELETE",
"path": "lists/dfce17dd1b/members/0620517b07414ec8fd56ce1ed4ae3b72"
}
@castroalves
castroalves / array-to-csv-using-for-vs-implode.php
Last active September 24, 2018 13:15
Performance Test: Array to CSV using For vs Implode
<?php
$arr_numbers = range(1,10000);
$total = count($arr_numbers);
$time_for = microtime(true);
$csv_for = '';
for($i = 0; $i < $total; $i++) {
if( $i == ($total - 1) ) {
/**
* Created by Cadu de Castro Alves
*/
(function() {
// Load Google Maps API
var mapCanvas = document.getElementById("map-canvas");
if( typeof mapCanvas !== 'undefined' ) {
var script = document.createElement('script');
<!-- listagem de fotos da busca -->
<div class="photo-results">
<div class="photo-item" data-id="0" data-title="Foto 1" data-photo="foto1.jpg" data-location="Barra da Tijuca" data-latitude="-19.945526900" data-longitude="-43.933424500"></div>
<div class="photo-item" data-id="1" data-title="Foto 2" data-photo="foto2.jpg" data-location="Copacabana" data-latitude="-19.945526900" data-longitude="-43.933424500"></div>
<div class="photo-item" data-id="2" data-title="Foto 3" data-photo="foto3.jpg" data-location="Leme" data-latitude="-19.945526900" data-longitude="-43.933424500"></div>
</div>
<!-- div onde o mapa será plotado -->
<div id="map-canvas"></div>
/**
* Define Post Type labels.
*
* @return array Post Type labels.
*/
protected function labels() {
$default = array(
'name' => sprintf( __( '%ss', 'odin' ), $this->name ),
'singular_name' => sprintf( __( '%s', 'odin' ), $this->name ),
'view_item' => sprintf( __( 'View %s', 'odin' ), $this->name ),