Skip to content

Instantly share code, notes, and snippets.

View eduardopintor's full-sized avatar

Eduardo Pintor eduardopintor

View GitHub Profile
@eduardopintor
eduardopintor / common-terminal-commands.md
Created September 3, 2019 04:34 — forked from chuckreynolds/common-terminal-commands.md
Common linux / terminal commands I always use but forget. So fuck it I'm saving em here

common terminal commands

ubuntu updates & clean

  • sudo apt update && sudo apt upgrade -y
  • sudo apt autoremove && sudo apt clean

copy mac public ssh key

  • pbcopy < ~/.ssh/id_rsa.pub

edit host file and flush dns after

UPDATE jp_blogs SET domain='blog.jovempan.uol.com.br';
UPDATE jp_site SET domain='blog.jovempan.uol.com.br';
UPDATE jp_options SET option_value='http://blog.jovempan.uol.com.br' WHERE option_name='siteurl';
UPDATE jp_options SET option_value='http://blog.jovempan.uol.com.br' WHERE option_name='home';
UPDATE jp_1_options SET option_value=replace(option_value, 'http://blog.jovempan.uol.com.br', 'http://blog.jovempan.uol.com.br') WHERE option_name='siteurl';
UPDATE jp_1_options SET option_value=replace(option_value, 'https://blog.jovempan.uol.com.br', 'http://blog.jovempan.uol.com.br') WHERE option_name='siteurl';
UPDATE jp_1_options SET option_value=replace(option_value, 'http://blog.jovempan.uol.com.br', 'http://blog.jovempan.uol.com.br') WHERE option_name='home';
@eduardopintor
eduardopintor / post-duplicate.php
Last active March 7, 2019 16:13
WP post duplicate
/*
* Function creates post duplicate as a draft and redirects then to the edit post screen
*/
function els_duplicate_post_as_draft(){
global $wpdb;
if (! ( isset( $_GET['post']) || isset( $_POST['post']) || ( isset($_REQUEST['action']) && 'els_duplicate_post_as_draft' == $_REQUEST['action'] ) ) ) {
wp_die('No post to duplicate has been supplied!');
}
/*
@eduardopintor
eduardopintor / delete-from-slack.php
Created January 24, 2019 21:19 — forked from kasperhartwich/delete-from-slack.php
Script to delete old files from Slack
#!/usr/bin/env php
<?php
date_default_timezone_set('GMT');
if (count($argv)<2) {
echo $argv[0] . ' <token> <until>' . PHP_EOL;
echo 'Example: ' . $argv[0] . ' abcd-12345678-123456789-12345 \'-3 months\'' . PHP_EOL;
exit;
}
//Begin SSL Load balancing fix
$server_opts = array("HTTP_CLOUDFRONT_FORWARDED_PROTO" => "https", "HTTP_CF_VISITOR"=>"https", "HTTP_X_FORWARDED_PROTO"=>"https", "HTTP_X_FORWARDED_SSL"=>"on", "HTTP_X_PROTO"=>"SSL", "HTTP_X_FORWARDED_SSL"=>"1");
foreach( $server_opts as $option => $value ) {
if ((isset($_ENV["HTTPS"]) && ( "on" == $_ENV["HTTPS"] )) || (isset( $_SERVER[ $option ] ) && ( strpos( $_SERVER[ $option ], $value ) !== false )) ) {
$_SERVER[ "HTTPS" ] = "on";
break;
}
}
//END SSL
function custom_admin_menu() {
$user = new WP_User(get_current_user_id());
if (!empty( $user->roles) && is_array($user->roles)) {
foreach ($user->roles as $role)
$role = $role;
}
if($role == "editor") {
global $submenu;
@eduardopintor
eduardopintor / function.php
Last active April 14, 2020 15:30 — forked from mattclements/function.php
Wordpress Disable Comments (add to function.php)
<?php
// Add to existing function.php file
// Disable support for comments and trackbacks in post types
function els_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
@eduardopintor
eduardopintor / README.md
Created April 22, 2018 23:22 — forked from magnetikonline/README.md
Nginx FastCGI cache configuration example.

Nginx FastCGI cache

Example /etc/nginx/nginx.conf using FastCGI (e.g. to PHP-FPM) with FastCGI cache enabled. This will capture returned data and persist it to a disk based cache store for a configurable amount of time, great for robust full page caching.

Will need to create a directory to hold cache files, for the example given here that would be:

$ sudo mkdir -p /var/cache/nginxfastcgi
$ chown www-data: /var/cache/nginxfastcgi
DELETE a,b,c FROM wp_posts a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_type = 'revision'
@eduardopintor
eduardopintor / gist:139affb4f89675697165b2cc85f1c40b
Created April 3, 2018 19:17
Delete All Existing WordPress Transients in MySQL Database
DELETE FROM `wp_options` WHERE `option_name` LIKE ('_transient_%');
DELETE FROM `wp_options` WHERE `option_name` LIKE ('_site_transient_%');