Recent Updates Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 10:01 am on April 13, 2015 Permalink | Reply  
    Categories: Announcements, Linux ( 7 )

    LAMP Stack for Humans – now available on Amazon 

    Lampstack-SoftcoverMy book LAMP Stack for Humans is now available on Amazon. It this 284 page guide I’ll walk you through the process of turning an old laptop into an always-on server. You can use it to run web applications in the comfort of your own home or office – no “cloud” required.

    Together we will configure the entire server: you will learn how to install CentOS, Apache, PHP and MySQL (or MariaDB) and WordPress. I will show you how you can reach your server from other computers on the network and how to create regular backups.

    Perfect for the Linux newbie and those who want to get started with web applications without spending money “in the cloud” (in my opinion THE WORST expression for describing remote computers).

    If you’re an avid reader of this site and have always wished that some instructions would be presented in a more cohesive form rather than in snippets, then LAMP Stack for Humans is perfect for you.

     

    Grab your free sample today, or read the entire book for free via Kindle Unlimited!

     

     
    • Falkon 2:28 am on October 21, 2015 Permalink | Reply

      Hi Jay
      I have a question regarding WP adding a Landing page for an existing site, meaning to add a new page which only displays a big logo in the start and be able to make that logo a roleover logo, and then the click would navigate a user to the main ( index page) if you will. i am new to WP and PHP wise I am still learning so I would not know how to add an extra page as the index page and the first index page turns say into a home.html. How would you do that? I trying to learn PHP and WP to what I work with in HTML & CSS and front end designs.
      Beforehand allow me to thank you for you time, help and assistance,

      Best Regards
      Falkon

      • Jay Versluis 2:55 pm on October 21, 2015 Permalink | Reply

        Hi Falkon, that’s a VERY off-topic question for this post…

        WordPress does have a way to display a static page as front page, instead of the default blog posts. You can change it like this:

        • for the blog, create a new page with a title (no content is necessary)
        • head over to Settings – Reading
        • under Front Page Displays, select your pages
        • hit Save and refresh the front page

        As for the roll-over image: insert an image into your static front page, then link that image to wherever you want (you can do that with Add Media from the page creation dialogue).

        Hope this helps!

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

    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!

     
  • 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 ( 95 )

    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 ( 95 )

    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 ( 95 )

    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 ( 95 )

    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 ( 95 )

    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.

     
  • Jay Versluis 8:47 am on May 7, 2017 Permalink | Reply  
    Categories: Windows ( 20 )

    How to start a Windows app with arguments from a shortcut 

    1. create a shortcut for your app somewhere
    2. right-click on the shortcut and head over to the Shortcut tab
    3. under Target, add your argument(s) after the closing quote
    4. hit OK, then double-click the shortcut
     
  • Jay Versluis 9:11 am on May 4, 2017 Permalink | Reply
    Tags:   

    Categories: Linux ( 95 )

    How to remove duplicate packages with yum 

    I’m working on a handful of servers that all have the same problem: when running yum, an error message appears that tells me a package called ntpupdate needs to be upgraded, but somehow this doesn’t work and the package is being skipped. Then follows a huge list of duplicate packages that are installed on those systems (probably installed by the automatic package updater within Plesk).

    Let’s see how we can fix such issues. (More …)

     
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