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
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 / 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 / functions.php
Created May 2, 2020 13:43 — forked from numediaweb/functions.php
Filter WordPress admin side navigation menues
function filter_admin_menues() {
// If administrator then do nothing
if (current_user_can('activate_plugins')) return;
// Remove main menus
$main_menus_to_stay = array(
// Dashboard
'index.php',
@Wendersonandes
Wendersonandes / customizer.php
Created April 11, 2020 01:04 — forked from purzlbaum/customizer.php
Google Font select for WordPress Customizer
<?php
new theme_customizer();
class theme_customizer {
public function __construct() {
add_action( 'customize_register', array(&$this, 'customize_linje' ));
}
/**
* Customizer manager demo
@Wendersonandes
Wendersonandes / koken-nginx.conf
Created August 13, 2019 06:36 — forked from spiffin/koken-nginx.conf
Nginx configuration for Koken 0.22.21 (2017)
server {
# General
# Listen on both ipv4 and ipv6
listen 80;
listen [::]:80;
server_name MYDOMAIN.COM;
def ProductFilters.option_with_values(option_scope, option, values)
# get values IDs for Option with name {@option} and value-names in {@values} for use in SQL below
option_values = Spree::OptionValue.where(:presentation => [values].flatten).joins(:option_type).where(OptionType.table_name => {:name => option}).pluck("#{OptionValue.table_name}.id")
return option_scope if option_values.empty?
option_scope = option_scope.where("#{Product.table_name}.id in (select product_id from #{Variant.table_name} v left join spree_option_values_variants ov on ov.variant_id = v.id where ov.option_value_id in (?))", option_values)
option_scope
end
# option scope
@Wendersonandes
Wendersonandes / Spree: Filter by brand.md
Created July 4, 2018 14:50 — forked from maxivak/Spree: Filter by brand.md
Spree: Filter Products by properties

Fix 'scoped' error for Rails 4

error: undefined method 'scoped' solution:

# config/initializers/scoped.rb
class ActiveRecord::Base
  # do things the modern way and silence Rails 4 deprecation warnings
 def self.scoped(options=nil)

options ? where(nil).apply_finder_options(options, true) : where(nil)