Recent Updates Page 2 Toggle Comment Threads | Keyboard Shortcuts

  • Jay Versluis 11:19 am on November 6, 2016 Permalink | Reply
    Tags:   

    Categories: Linux ( 85 )

    How to extract tar.xz files on CentOS 

    CentOS-LogoI’ve recently come across a tarsal files that used xz compression (namely the Python source code).

    This means that my usual way of extracting a tarsal via the command line using the following command did not work:

    tar -zxvf Python*
    
    gzip: stdin: not in gzip format
    tar: Child returned status 1
    tar: Error is not recoverable: exiting now

    That had me stumped! Turns out that files with a tar.gz ending can be extracted this way (because the use gzip compression, specified by the z parameter). If tar is instructed to use this format on a tar.xz file, it fails.

    The solution: specify the xz compression, using the capital letter J, like this:

    tar -Jxvf Python*
    [massive list of files goes here]

    Another Linux mystery solved – thanks to Justin Solver for this tip!

     
  • Jay Versluis 11:06 am on November 5, 2016 Permalink | Reply
    Tags: Logitech   

    Categories: Mac OS X, Windows ( 30 )

    How to fix problems with Logitech Unifying Receivers 

    screen-shot-2016-11-04-at-17-12-10I’ve recently bought a new Logitech K360 keyboard for my HP Z600 workstation. I also had a Logitech M325 mouse, both of which came with Unifying USB receivers. I could plug both receivers in, and both devices would work great.

    However, I heard great things about these little receivers and wanted to free up a USB port, and thought I’d connect both devices to the same receiver. Apparently you can connect up to 6 devices to one receiver and store any spare ones inside the mouse or keyboard. Being an all-efficient belt-and-braces kinda guy, I tried my luck.

    Turns out it was relatively easy to pair both devices to the same receiver, thanks to a small piece of software that can be found here, along with instructions on how to use it:

    It all worked fine on my Windows 10 machine, until I wanted to use the mouse (not the keyboard) with my Mac. I know, it’s exotic, and perhaps I should have just bought another mouse. But really, there’s only so much space on my desk, and I really don’t need more clutter in front of me for just an occasional switch.

    I regretted pairing both devices to the same receiver and wished I hadn’t done that, for this very eventuality. So now I had to figure out how to UN-pair both devices again and put them back to how things used to be (before I started messing with them). (More …)

     
  • Jay Versluis 10:54 am on November 4, 2016 Permalink | Reply  
    Categories: Mac OS X, Screencast ( 30 )

    How to launch a Mac App with Command Line Parameters from the Dock 

    In this video I’ll show you how to launch a Mac App from the Command Line, so that we can pass parameters. I’ll also explain how to wrap up such a command into your own app and add an icon to it, so that you can launch it from the dock with a single click.

    This can be useful if you need to convince Google Chrome or any other app to launch with certain parameters and modify its behaviour somehow. In my example I’m using Blender, and I’m using a startup parameter to change its default render engine upon launch. The same principles apply to any app you need to launch with startup parameters.

    The process is as follows:

    • find out the full path of the app you want to launch
    • try launching your app from the command line
    • now add parameters to the end of the launch command
    • create an Automator App
    • change its icon from from the generic Otto Icon to your desired app’s icon
    • drag your new launcher app into the dock

    I’ll explain all the gory details in this video.

    Enjoy!

     
  • Jay Versluis 11:39 am on November 3, 2016 Permalink | Reply
    Tags:   

    Categories: Linux ( 85 )

    How to boot CentOS 7 into Command Line or GUI Mode 

    CentOS-LogoIn CentOS 7 we can use the systemctl command to select which mode the OS boots into. If you have a GUI like Gnome or KDE installed, it’s easy to boot directly into your preferred environment.

    To find out what mode CentOS is currently using, use this:

    systemctl get-default
    

    This will give you one of two “targets”, either

    • multi-user.target (the command line), or
    • graphical.target (the Windows-like GUI)

    To change from one to the other, use one of these commands:

    systemctl set-default multi-user.target
    systemctl set-default graphical.target
    

    What happened to runlevels?

    In previous versions of CentOS, switching boot modes was achieved through runlevels. Those were saved in /etc/inittab, but this file is no longer used by CentOS 7 and above. However, the file still exists and contains a little extra info this matter, including how to change boot modes:

    # multi-user.target: analogous to runlevel 3
    # graphical.target: analogous to runlevel 5
    #
    # To view current default target, run:
    # systemctl get-default
    #
    # To set a default target, run:
    # systemctl set-default TARGET.target
    
     
  • Jay Versluis 4:29 pm on August 23, 2016 Permalink | Reply  
    Categories: Mac OS X ( 30 )

    How to kill a Mac App via the Command Line 

    Sometimes it’s’ necessary for us to force-close an app on our Mac if it’s no longer responding to our commands. Usually we’d do that by pressing CMD+OPT+ESCAPE, which brings up a handy window from which we can choose a troublesome app.

    Screen Shot 2016-08-23 at 16.10.14

    But sometimes, this keyboard combination won’t work – for example, if we’re dealing with a remote Mac to which no physical keyboard is attached. In such cases, we can choose to force-close an app via the command line. Let me show you how to do that.

    Connect to your Mac via SSH using a Terminal Session and find out what apps are currently running. We’ll so that with the top command:

    top -u

    Using the -u switch tells top to list the app with the highest CPU usage over time first. The command will display a list of running processes, much like this:

    Screen Shot 2016-08-23 at 16.15.04

    Take a look at the list and make a note of the troublesome app. In my case it’s Carrara, using 165% of my CPUs resources. By definition impossible, but let’s not worry about that. The important thing is this app’s PID (Process ID). Write it down or take a screenshot, we’ll need it in amount to kill the app (mine is 5964).

    Press CTRL+C to stop top and return to the command line. Now issue the following command, replacing 5964 with your own PID:

    kill -9 5964

    And that’s it: the troublesome app has been force-closed and should vacate your system sharpishly. For more information on both top and kill, check out their respective man pages on your Mac.

     
  • Jay Versluis 5:43 pm on August 7, 2016 Permalink | Reply
    Tags:   

    Categories: iOS, Mac OS X ( 222 )

    How to make Notes App sync properly on iOS 

    ios9-notes-app-iconHave you ever wondered why some notes seemingly sync just fine between your iOS devices, but others do not? Wether a note is not fully updated, or you find a duplicate entry in the list, it can be an exercise in frustration.

    But fret not, it doesn’t have to be! This is not a bug in the Notes app; it’s the way we’re using it.

    Let me show yo what you can do to avoid such problems, and how they can happen in the first place.

    Why do we sometimes get random duplicate notes?

    This has to do with the way the app stores data in the cloud. Notes saves your content only when you close the note, or when you switch away from it. Your note is not saved while you’re typing it.

    Likewise, iOS can only “save over” the current note if you’re not actively editing it. Leaving it open, even if you’re only looking at it, means your note is locked for edits from other devices.

    When you make a change on device A, and the same note is opened and edited on device B, then iCloud cannot save your changes to the current note. Hence it creates a duplicate entry. This is a safety mechanism so that your changes are saved rather than lost, and you can decide which copy you’d like to keep when you’re done.

    How to avoid sync trouble on iPhone

    So on iPhone, the solution is simple: always return to the list view of all your notes. Do not leave a note open. That way, another device can edit its contents without trouble.

    How to avoid sync trouble on iPad and Mac?

    On the iPad as well as your Mac, things are a little different due to the nature of the Split View Controller. It displays both the list of your notes, as well as a note next to it. Even when you hold your iPad in portrait mode and cannot see the list view, one note is ALWAYS open and displayed, and therefore cannot be edited by another device. That’s usually when and why iOS (or macOS) saves a duplicate.

    To avoid this situation, make sure you switch to a note that you’re unlikely to edit from another device. Perhaps create a “dummy note” without content and switch to it when you’re finished with the Notes app.

    Remember you can look at a note even if it’s open on another device – it’s just that when editing an open note, trouble keeps in.

    Hope this helps 🙂

     
    • juliav305 8:26 pm on August 7, 2016 Permalink | Reply

      Another great article thank you – another part of the system that made me think I was going slightly crazy with duplicate notes of the same thing or not syncing up at all. Mystery solved 🙂

      • Jay Versluis 8:33 pm on August 7, 2016 Permalink | Reply

        Thanks Julia 🙂

      • Jay Versluis 8:34 pm on August 7, 2016 Permalink | Reply

        Thank you, Julia 🙂

  • Jay Versluis 4:45 pm on August 7, 2016 Permalink | Reply
    Tags:   

    Categories: iOS ( 222 )

    How to sync past events in the Apple Calendar App on iOS 

    Apple-Calendar-Official-iconHave you ever been shocked to find out that a new iOS device does not show your old calendar entries, even though future events sync fine across your other devices?

    We’ve all been there! Turns out there’s a default setting in the Calendar App that only synchronises the last 1 month of entries. As if your life before that point didn’t matter. Kind of like Apple’s policy of not supporting hardware older than 4 weeks. But I digress…

    To fix this problem, open the Settings App on your iOS device, then head over to Mail, Contacts, Calendars and scroll all the way to the bottom. Find the Calendars section. There’s a section here called Sync, and by default it says “Events 1 Month Back”.

    Change this to All Events, and magically, past events are now synchronised on this device as well.

    Photo Aug 07, 16 38 37

    You must make this change on ALL your iOS devices so that all past calendar entries can be pushed to every device. Note that there is no such setting on the Calendar App for OS X.

    Another mystery solved!

     
  • Jay Versluis 12:11 pm on June 11, 2016 Permalink | Reply  
    Categories: PHP, WordPress ( 26 )

    How to set WordPress Categories depending on the Post Title 

    I was working on a project the other day that required to determine which category a new post would go into, depending on the post title. This was important because posts were automatically acquired without the web interface, and in this workflow there was no way to pick a category other than the default.

    In our case we wanted to use a post fix in the title to determine which category was to be picked: for example, if a post title would end with “_ONE”, it should end up in Category 1, and if it ends up with “_TWO” it would end up in Category 2.

    Thankfully there’s a hook called save_post that is called every time a post is updated. At this point we can check what the post title is, determine the post fix, and set the correct category. Here’s a function that does just that:

    function set_my_categories($post_ID) {
    	
    	// grab the current title
    	$title = get_the_title($post_ID);
    	
    	// set the category depending on the last four characters of the title
    	// _ONE = Category 1
    	// _TWO = Category 2
    	$postfix = substr($title, -4);
    	if ($postfix == '_ONE') {
    		wp_set_post_categories($post_ID, array(1));
    	}
    	if ($postfix == '_TWO') {
    		wp_set_post_categories($post_ID, array(2));
    	}
    }
    add_action('save_post', 'set_my_categories');
    

    If a post fix is not present, the categories will not be changed.

    For this example I’m assuming that my categories are actually 1 and 2 on the system, something that’s not really the case. To determine the correct value set under wp_set_post_categories, I usually head over to Posts – Categories, select the category I want to use and check the URL of what WordPress gives me. Say the URL looks like this:

    http://domain.com/wp-admin/term.php?taxonomy=category&tag_ID=366&post_type=post

    then the tag_ID parameter hints that my category has an ID of 366, and that’s the value we need to use.

    And if a post needs to go into two categories, separate the category IDs with a comma like so:

    wp_set_post_categories($post_ID, array(2,3));

    Removing the post fix before the title is displayed

    Since our post fix is for internal purposes only, we may not want it to appear as part of the actual post title on the front page. But we also don’t want to remove it from every post once the category has been set and still have a reference in the admin interface. So the way to do it is to simply suppress it before out theme prints it out.

    The following code will do just that: if a post fix is present, curb the title. If not, leave the title unchanged.

    // curb title if we have a post fix
    $title = get_the_title();
    $postfix = substr($title, -4);
    if ($postfix == '_ONE' || $postfix == '_TWO') {
    	$title = substr($title, 0, -4);
    }
    // use echo $title to print the post title in your theme
    

    And there we have it. The same principle can be used if your title contains a certain keyword and you want to use it to add the post to a particular category automatically.

     
  • Jay Versluis 10:01 pm on April 2, 2016 Permalink | Reply
    Tags:   

    Categories: WordPress ( 135 )

    P2 Header Ad – Version 1.6 released 

    P2 Header Ad IconI’ve just released a new version of my P2 Header Ad plugin! It fixes a few issues I’ve come across in debug mode:

    • styles are now loaded via wp_enqueue_scripts hook
    • fixed a debug warning that assumed a constant rather than a value
    • verified compatibility with WordPress 4.5

    There’s still a lone warning that appears in WordPress 4.5 Debug Mode. It reads something like “get_currentuserinfo is deprecated since version 4.5! Use wp_get_current_user() instead”.

    This isn’t actually triggered by my plugin, but rather by the current version of P2 (1.5.8 and earlier). I’m sure the team will fix it very soon.

    As always, you can download the plugin from

     
  • Jay Versluis 12:57 pm on March 27, 2016 Permalink | Reply
    Tags: ,   

    Categories: Linux, Plesk ( 85 )

    How to fix “MLSD unable to build data connection” in ProFTP 

    Filezilla IconI’ve come across an odd problem today on a server that’s been working fine for all kinds of FTP traffic for many years. Turns out that today, FileZilla started complaining about explicit TLS connections (when available) and gave the following error message:

    425 MLSD unable to build data connection: operation not permitted

    Clients could still connect, but no directory content was displayed, nor was uploading new files possible. Rats, I thought. This was on a CentOS 6 server with Plesk 12 running without a hitch otherwise.

    Turns out that by default, ProFTP is configured to re-use TLS sessions – but it appears that this behaviour freaks out FileZilla, which in turn doesn’t like it and throws an error instead. This did not affect plain (non-secure) sessions.

    Thankfully, Adam Stohl knows the answer to this problem: tell ProFTP not to re-use TLS sessions. Open /etc/proftp.conf and add the following line to the bottom of the file:

    TLSOptions NoSessionReuseRequired

    The ProFTP service in Plesk is part of xinetd, so for those changes to take effect, simply restart it with this:

    service xinetd restart

    And voila, TLS connections can happen again. Thanks, Adam – you’re a life saver!

     

     
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