Updates from Jay Versluis Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 6:38 pm on November 5, 2017 Permalink | Reply
    Tags:   

    Categories: WordPress ( 137 )

    How to disable JetPack nag messages in the WordPress Admin interface 

    I really like WordPress, and I really like JetPack. I use the plugin on many client websites, who usually have their own WordPress.com  account, which is necessary to enable the plugin successfully.

    Most of them however choose not to sign up for a payment plan, which as of 2017 leads to (now rather annoyingly frequent) JetPack upsell messages at the top of the admin screen. So I as the administrator, am constantly exposed to such messages, and I was wondering how to suppress them – not being the target audience here.

    Thanks to a super helpful article by Matt Medeiros I found a great solution with this one-liner of code he as kindly supplied on his website, together with his opinion on such messages:

    /* remove JetPack upsell messages */
    /* https://mattreport.com/disable-jetpack-upsell-ads/ */
    add_filter( 'jetpack_just_in_time_msgs', '_return_false' );
    

    Add this to your child theme’s functions.php file and those admin nags are history!

    Thanks Matt!





     
  • Jay Versluis 10:35 am on September 26, 2017 Permalink | Reply
    Tags:   

    Categories: Linux ( 96 )

    How to find out which version of GNOME you’re using 

    In the GNOME desktop, there is no obvious way to tell which version you’re running by way of the GUI. Instead, we need to consult the command line and try out a couple of commands to find out more. Here’s how.

    Let’s open a Terminal session and do some hacking.

    GNOME 2.x

    If you’re running GNOME 2.x (under CentOS 6 for example), you need to run the following command:

    gnome-session --version
    
    gnome-session 2.28.0

    You may need to prefix this command with sudo, otherwise it will tell you that you’re alrady running a GNOME session.

    Should the above not work, you’re likely on GNOME 3 (see next).

    GNOME 3.x

    GNOME 3 uses a different command, namely this one:

    gnome-panel --version
    
    gnome-panel 3.24.2

    If you don’t know which version of the GNOME panel you’re using (which is likely), try both commands. One of them will work, the other one won’t.





     
  • Jay Versluis 12:47 pm on September 16, 2017 Permalink | Reply  
    Categories: WordPress ( 137 )

    How to fix the Visual Editor or Text Editor in WordPress when it’s not working 

    I had a weird phenomenon on a Multisite installation the other day. I can’t tell you with which update exactly it happened, as I only write a post on that site once every couple of months, but it must have been around the 4.7 or 4.8 upgrade. Here’s what was happening:

    I could log into the site fine, I could display all posts in the backend fine, but editing them, or creating a new post (or page) resulted in an unresponsive editor window. Neither the Visual Editor nor the standard Text Editor wanted to accept any keyboard input. Moreover, none of the buttons could be pressed, including the Publish button.

    The rest of the admin interface looked and behaved completely normal. I could even write posts from the iOS app, so fundamentally the installation wasn’t broken, just the editor part of it. Made no sense to me at all.

    Things I’ve tried

    I tried the usual tricks for getting rid of such a spurious affair:

    • re-install WordPress manually
    • disable all plugins
    • use a different default theme (in fact, I’ve tried several)
    • try logging in as a different user
    • since this was multisite, try writing a post on another site (same issues there)
    • since this was an installation managed from Plesk via the WP Toolkit, try more lax security settings

    I probably tried other things, but none of it was making that editor working again. I didn’t understand what was going on.

    The Solution

    The solution came after extensive research, one part of which lead me to this thread in which Peter Luit explained a related problem that he could fix by defining a constant in the wp-confg.php file. I had never heard of it either:

    define('CONCATENATE_SCRIPTS', false);

    Turns out that this constant is enabled by default and means that all JavaScript files are loaded with a single call, rather than multiple calls to multiple files. The idea is that, if your site is healthy, and every single JavaScript file is working fine, all of them together will execute and work fine too. However, should one in the middle not work so well, then the rest of them won’t be executing, and I guess that’s what happened on my installation.

    By setting this constant to false, each JavaScript file is loaded individually, resulting in more http requests to the server (potentially making the overall load time slower), but every JavaScript file can be executed individually. If one isn’t working, none of the others are impacted. Hence, now my editor is working again, however I still have at least one JavaScript file that has an issue executing. Finding which one would be the next step.

    So this constant isn’t a “fix” as such, it’s part of a debug strategy. But it’s great to have my site back up and running so I can continue to write posts.

    Thanks for sharing, Peter!





     
    • My site 10:38 pm on September 25, 2017 Permalink | Reply

      Hi, I try everything but still not work. All do like you and i can not swich from text to visual when edit post. When i start new post i can swich and that it work but if i write one word in post i again can not change visual to text or text to visual

      • Jay Versluis 10:41 am on September 26, 2017 Permalink | Reply

        The trouble is that there are literally a million reasons why the text or visual editor might stop working. The web is full of disappointed people trying to figure to why, and there are a great number of solutions out there. Most of the time, it turns out to be a plugin conflict or a conflict between the theme you’re using and a plugin. To make sure WordPress itself is working fine, start by switching off ALL plugins and switch to one of the recent default themes (like TwentySeventeen, TwentyThirteen, etc). Then see if the editor works. If it does, switch to your own theme. Try again. If all works well, switch on one plugin at a time and test after each plugin.

        If it’s not your theme or your plugins, try a re-install. Then a database repair. Finding those types of problems is really time consuming and extremely tricky. All I can wish you is good luck for your hunt to find the culprit!

  • Jay Versluis 4:54 pm on June 28, 2017 Permalink | Reply
    Tags: C,   

    Categories: Mac OS X ( 34 )

    How to use Xcode for C and C++ development 

    Not only is Xcode an excellent IDE for iOS and macOS apps in both Swift and Objective-C; it does just as fine a job for regular C and C++ code. This includes all the features we know and love, such as code completion, version control, and all the rest of it.

    Let’s see how to use Xcode 8.3 for C and C++ development.

    (More …)





     
  • Jay Versluis 3:39 pm on June 26, 2017 Permalink | Reply
    Tags: ,   

    Categories: Mac OS X ( 34 )

    How to fix “can’t log into YouTube from Safari” on macOS 

    Something rather strange happened to me today: Safari 10 on macOS Sierra refused to let me login to YouTube. All it did was constantly refresh the page in an endless loop, or just display the front page of YouTube. I cleared the caches, reset the history, but no trick seemed to solve the problem.

    When I dug deeper into the Preferences, I found something under Privacy that finally fixed it. Let me share with you what worked on my system.

    • head over to Safari – Preferences
    • select the Privacy tab
    • you’ll see a window like this one:

    • select Manage Website Data
    • after a few moments you’ll see a LONG list of websites that have saved cookies on your machine over time
    • in the top right corner, search for YouTube
    • you’ll see something like this:

    • select the YouTube.com entry and hit Remove, followed by Done
    • now surf back to YouTube and login – this time it’ll work

    What we’ve just removed were not just cookies, but also HTML local storage data, as well as cache data specific to the YouTube website. I guess cached stuff can get outdated, or not properly deleted when we close our browser in a hurry.

    The principle should work for other websites too, should they give you trouble. If you’re sick and tired of any website saving data to your system, consider switching to the “Always Block” option seen in the first screen shot.

     





     
  • Jay Versluis 3:11 pm on June 25, 2017 Permalink | Reply
    Tags: Command Line   

    Categories: Linux ( 96 )

    How to rename a batch of files in Linux 

    Bulk renaming files can be done with the rename command. It shares many similarities with cp and mv, but its simplicity can be so staggering that its difficult to figure out how to use it.

    If we just type “rename” at the command prompt, all we get is the message

    rename
    call: rename from to files...

    While technically correct, what on earth does it mean? How do we use rename?

    Let’s do a little exercise. Imagine we had a batch of files, perhaps something like “Title 101.mp4” to “Title 110.mp4”. Let’s create some empty files with those names in a test directory:

    mkdir test
    cd ./test
    touch 'Title '{101..110}.mp4
    ls

    So far so good. Now we’d like to rename those files so they read “New Title 101.mp4” to “New Title 110.mp4”. Here’s how it works:

    rename 'Title' 'New Title' *.mp4

    Technically, this follows what the command showed us earlier: “rename from to files…”. Still I feel a little explanation is in order.

    For the rename command to work, we don’t need to specify the full file name, nor that we want to rename a batch of files. The command will rename anything that it encounters. All it needs to know is which string to replace with which other string. Those are the first two parameters we give it, in our case wrapped in single quotes because we have a space character in our titles.

    The third parameter tells rename where the files live that we want to rename. In our example it was here in the current directory, but it could be anywhere on the system. By specifying *.mp4, only files with that ending will be renamed, all other files will be left in peace.

    I hope this helps to understand rename a little better.





     
  • Jay Versluis 12:01 pm on June 18, 2017 Permalink | Reply
    Tags:   

    Categories: Linux ( 96 )

    How to exit VI with or without saving 

    Although many alternatives exist, I like using vi for all my command line editing needs. To save changes, I usually use SHIFT + Z + Z, exiting vi under most circumstances.

    But sometimes, this trick doesn’t work because of write permission problems. In such cases, vi doesn’t close with the above command. Instead, we must either stash our changes in another file, or quit the session without saving. Here’s how to do that.

    Quit vi without saving:
    :q!

    Save current file under a different name:
    :w newfile





     
  • Jay Versluis 4:36 pm on June 17, 2017 Permalink | Reply
    Tags:   

    Categories: Linux ( 96 )

    How to read command line parameters in BASH Scripts 

    Shell Scripts (BASH Scripts) can access command line parameters using the the variables $1, $2, $2 and so forth, up to $9. In fact, more parameters can be accessed by using curly brackets, like ${10}, ${187} and so forth.

    Here’s an example:

    #!/bin/bash
    
    if [[ $1 == "x" ]]; then
      echo "Statement is true"
    else
      echo "Statement is false"
    fi
    

    If we run the script with like this

    script.sh x
    

    it will tell us the statement is true. Otherwise, it’ll tell us the opposite.

    Note the whitespace around the evaluation: [[ ]] is actually a command (much like the == operator) and therefore needs to be surrounded with whitespace.





     
  • Jay Versluis 3:10 pm on June 17, 2017 Permalink | Reply
    Tags:   

    Categories: Linux ( 96 )

    How to read command line parameters in PHP Shell Scripts 

    We can access parameters passed via the command line in our PHP shell scripts. Those are stored as an array in the variable $argv. Consider this:

    #!/usr/bin/php
    <?php
    
    echo var_dump($argv);
    echo "\n";
    
    if ($argv[1] == 'x') {
      echo "The parameter is x.";
    } else {
      echo "The parameter was something else.";
    }
    

    The first part of the script prints out all parameters that have been given, while the second part checks if the parameter was “x” or not. Note that the first item in the array ($argv[0]) will be the the first item on the command line, i.e. the file name and path to this very script. $argv[1] is the first parameter, $argv[2] the second, and so forth.

    We can call the script with

    script.php x
    

    to give it one parameter, or with

    script.php x y z
    

    to give it three parameters.





     
  • Jay Versluis 11:29 am on June 17, 2017 Permalink | Reply
    Tags: tar   

    Categories: Linux ( 96 )

    How to extract files from a bz2 archive in Linux 

    If you’ve ever tried to decompress a file that ends in tar.bz2 using the tar command with the standard -x option, you’ll have noticed that it doesn’t work. That’s because some versions of tar don’t understand the bzip2 codec used in these archives.

    However, you can tell tar to use this option by specifying the -j parameter, like so:

    tar -xjf yourfile.tar.bz2
    

    If this still doesn’t work, we can use the dedicated bzip2 command like so:

    bzip2 -d yourfile.tar.bz2
    

    The -d switch stands for “decompress”. Notice that this will extract all files and delete the original .bz2 file by default. Very convenient indeed! If you’d like to keep it, just pass the -k switch (for “keep”), like this:

    bzip2 -dk yourfile.tar.z2
    

    Checkout man bzip2 for more details, or pass the –help for as quick overview.





     
c
compose new post
j
next post/next comment
k
previous post/previous comment
r
reply
e
edit
o
show/hide comments
t
go to top
l
go to login
h
show/hide help
shift + esc
cancel