Skip to content

Instantly share code, notes, and snippets.

View Wendersonandes's full-sized avatar

Wenderson Fernandes Wendersonandes

  • Emerge
  • Belo Horizonte, Brazil
View GitHub Profile
@Wendersonandes
Wendersonandes / defaul_layout_rails.md
Last active September 4, 2023 21:25
A note about default layout on rails

Rails take the controller name and devise/sessions, devise/registrations etc inherit from the controller Devise. That way you can just stick with devise.html.erb as layout for every controller inside devise.

You can test that behaviour and create layout layouts/posts.html.erb and you will see that every action inside posts_controller will be using that as far as you will be not changing that :)

application_controller is the reason why application layout is default when you are not using some from inherited controller names.

1) Setup Server on Vultr
Select “create New Server(e.g. 123.123.123.123)”, select “Ubuntu 14.04 LTS”
Once your server has been created, wait for installation to complete.
SSH into your Server as root and run the following commands:
# login server by SSH
ssh root@dokku.me
# Updating apt-get
sudo apt-get update # Fetches the list of available updates
sudo apt-get upgrade # Strictly upgrades the current packages
sudo apt-get dist-upgrade # Installs updates (new ones)
<?php
// via http://wordpress.stackexchange.com/questions/17325/how-to-enable-hierarchical-permalinks-for-hierarchical-taxonomies
// and http://wordpress.org/support/topic/hierarchical-custom-taxonomy-permalinks
register_taxonomy('genre',array('book'), array(
'hierarchical' => true, // this makes it hierarchical in the UI
'labels' => $labels,
'show_ui' => true,
'query_var' => true,
'rewrite' => array( 'hierarchical' => true ), // this makes hierarchical URLs
@Wendersonandes
Wendersonandes / clinup
Created October 22, 2021 13:10 — forked from petskratt/clinup
Use wp-cli to clean up WordPress installs (force core & plugins reinstall, track changes in git allowing easy reverts etc)
#!/usr/bin/env bash
# for debug output, uncomment:
#set -x
function help {
echo "WordPress cleanup -v 0.5 2018-06-26 / peeter@zone.ee
Usage:
require 'nokogiri'
require 'open-uri'
# Get a Nokogiri::HTML:Document for the page we're interested in...
doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
# Do funky things with it using Nokogiri::XML::Node methods...
####
@Wendersonandes
Wendersonandes / reset_id_sequence_activerecord
Created September 7, 2020 19:53
Reset postgres tables on Rails
ActiveRecord::Base.connection.reset_pk_sequence!('table_name')
@Wendersonandes
Wendersonandes / gist:3f21325f2343b6518de2656d34efe162
Created June 9, 2020 22:26 — forked from lopezjurip/gist:a817e96ec833e7667274
DigitalOcean+Rails+Puma+Dokku+Postgress
# Based on: http://donpottinger.net/blog/2014/11/17/bye-bye-heroku-hello-dokku.html
# Add to gemfile:
ruby '2.1.2'
gem 'pg'
gem 'puma'
gem 'rails_12factor'
gem 'searchkick'
gem 'typhoeus'
@Wendersonandes
Wendersonandes / reorder-wordpress-admin-menu.php
Created May 3, 2020 19:38
Reorder Wordpress Admin Menu Items
/**
* Activates the 'menu_order' filter and then hooks into 'menu_order'
*/
add_filter('custom_menu_order', function() { return true; });
add_filter('menu_order', 'artvsm_new_admin_menu_order');
/**
* Filters WordPress' default menu order
*/
function artvsm_new_admin_menu_order( $menu_order ) {
// define your new desired menu positions here
@Wendersonandes
Wendersonandes / debug_admin_menu.php
Created May 2, 2020 13:45
Debug wordpress admin menu array
add_action( 'admin_init', 'wpse_136058_debug_admin_menu' );
function wpse_136058_debug_admin_menu() {
echo '<pre>' . print_r( $GLOBALS[ 'menu' ], TRUE) . '</pre>';
}