Skip to content

Instantly share code, notes, and snippets.

View gmmcal's full-sized avatar
💻
https://www.gustavocunha.dev

Gustavo Cunha gmmcal

💻
https://www.gustavocunha.dev
View GitHub Profile
@gmmcal
gmmcal / .p10k.zsh
Last active March 31, 2024 06:38
dotfiles
# Generated by Powerlevel10k configuration wizard on 2022-05-09 at 23:10 CEST.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 54401.
# Wizard options: nerdfont-complete + powerline, small icons, unicode, lean, 2 lines,
# dotted, full frame, lightest-ornaments, sparse, many icons, fluent,
# instant_prompt=verbose.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with lean prompt style. Type `p10k configure` to generate
# your own config based on it.
#
@gmmcal
gmmcal / .gitlab.yml
Created August 17, 2018 21:20
FTP deployment with Dandelion gem and Gitlab
before_script:
- apt-get update -qq && apt-get install -y -qq pkg-config cmake
- ruby -v
- which ruby
- gem install dandelion --no-ri --no-rdoc
- gem install net-sftp --no-ri --no-rdoc
deploy:
script:
- dandelion deploy $CI_COMMIT_SHA
# fetch all date_pub from active Post already ordered
dates = Post.where(active: true).order(date_pub: :desc).pluck(:date_pub)
# normalize all data into an array and remove duplication
data = dates.map { |date| { year: date.year, month: date.strftime('%B') } }.uniq
# group all data by year
year_groups = data.group_by { |group| group[:year] }
# normalize data to be more organized
# group[0] is year, group[1] is a group_by result. something like [{:year=>2018, :month=>"March"}, {:year=>2018, :month=>"January"}]
# final data will be similar to [{2018=>["March", "January"]}, {2017=>["April", "May", "December"]}]
groups = year_groups.map {|ygroup| { ygroup[0] => ygroup[1].map {|month| month[:month] } } }
@gmmcal
gmmcal / cleanup.rake
Last active December 28, 2017 12:35
Delete reviews from the last 24h
task :cleanup => :environment do
Review.over_24_hours.destroy_all
end
# You can call it as rake cleanup on terminal
@gmmcal
gmmcal / Register Taxonomy
Created September 17, 2014 12:11
Criando um plugin para Wordpress usando Custom Post Types - Tutorial 5
register_taxonomy(
"categorias",
array("demonstracao"),
array(
"public" => true,
"show_in_nav_menus" => true,
"show_ui" => true,
"show_tagcloud" => false,
"hierarchical" => true,
"label" => "Categorias",
@gmmcal
gmmcal / Register Post Type
Created September 17, 2014 12:10
Criando um plugin para Wordpress usando Custom Post Types - Tutorial 4
$labels = array(
'name' => 'Demonstração',
'singular_name' => 'Demonstração',
'add_new' => 'Adicionar novo',
'add_new_item' => 'Adicionar nova demonstração',
'edit_item' => 'Editar Demonstração',
'new_item' => 'Nova Demonstração',
'all_items' => 'Todas as Demonstrações',
'view_item' => 'Ver Demonstração',
'search_items' => 'Pesquisar Demonstração',
@gmmcal
gmmcal / Plugin definition
Created September 17, 2014 12:10
Criando um plugin para Wordpress usando Custom Post Types - Tutorial
/*
Plugin Name: Demonstração
Plugin URI: http://www.gmmcal.com.br
Description: Plugin de Demonstração
Author: Gustavo Cunha
Version: 1.0
Author URI: http://www.gmmcal.com.br
*/
@gmmcal
gmmcal / Class Init
Created September 17, 2014 12:09
Criando um plugin para Wordpress usando Custom Post Types - Tutorial 2
add_action("init", "demonstracaoInit");
function demonstracaoInit() {
$d = new Demonstracao();
$d->init();
}
@gmmcal
gmmcal / Base Class
Created September 17, 2014 12:08
Criando um plugin para Wordpress usando Custom Post Types - Tutorial 1
class Demonstracao {
function Demonstracao(){
}
function init(){
// algum código aqui
}
}