Meteor get Collections by Reference

This short code sample will show you how to get access to a Collection by reference.

The root variable is essentially referencing the this global but detects the correct global reference based on where the client is running.

var colData = function (collectionName) {

var root = Meteor.isClient ? window : global;

var col = root[collectionName];

return col.find().fetch();
}
colData('Things');

 

References:
https://dweldon.silvrback.com/collections-by-reference

Iron Router Multiple Data Context with Meteor

Here’s how to do it:

Router.route('/things', {

    name: 'things',    

    waitOn: function () {

        return [this.subscribe('thing'),this.subscribe('thinga')];

    },

    data: function () {

        return {

            thing: Thing.find(),

            thinga: Thinga.findOne({type: "abc"})

        };

    },

    onAfterAction: function () {

        Meta.setTitle('Things');

    }

});

To access the data context in the Template use the following syntax:

console.log('Template.instance().data.thinga.propertyname', Template.instance().data.thinga.propertyname);

 

References:

https://iron-meteor.github.io/iron-router/

Set Fn key to always on with Apple keyboard

If you’re using an Apple keyboard with Linux and want to use the Function keys normally, for example F2 to rename files, it’s possible to do so with a simple modification.

Open a terminal and run this command:

sudo -s 'echo 2 > /sys/module/hid_apple/parameters/fnmode'

If you want something other than Function keys taking precedence there are other options.

The following are the accepted values:

  • 0 = disabled : Disable the ‘fn’ key. Pressing ‘fn’+’F8’ will behave like you only press ‘F8’
  • 1 = fkeyslast : Function keys are used as last key. Pressing ‘F8’ key will act as a special key. Pressing ‘fn’+’F8’ will behave like a F8.
  • 2 = fkeysfirst : Function keys are used as first key. Pressing ‘F8’ key will behave like a F8. Pressing ‘fn’+’F8’ will act as special key (play/pause)

 

References:

https://superuser.com/questions/79822/how-to-swap-the-fn-use-of-function-keys-on-an-apple-keyboard-in-linux/1141657

How to Fix Ubuntu Landscape – Invalid Machine token

Ubuntu Landscape allows you to keep systems updated when deployed in large clusters.

If you clone a machine and look in its logs you might find an error message similar to the ones below.

Error message:

during refresh: cannot check: cannot send status to server: bad server status 403 (URL: https://livepatch.canonical.com/api/machine/dfb8755a82202da0678c99065c9501ab): {"error": "Invalid Machine Token"}

You may also see this warning in the motd.

 * Canonical Livepatch is enabled.
- Livepatch server check failed.
Please see /var/log/syslog for more information.

 

The solution is to remove, reinstall landscape and register the node again with your license key.

apt remove landscape-common 
apt install landscape-common

It’s not clear if this is a bug or intended behavior for Landscape.

For large deploymens this could be problematic.

Fix slow GUI, sluggish interface with Mint Cinnamon

 

If you have been using your system heavily, with multiple workspaces, various applications that are not entirely memory efficient, these combined factors can lead to your interface feeling sluggish.

In order to resolve this issue without having to restart the entire system issue this command in a terminal windows to restart mind and preserve your workspaces and windows.

pkill -HUP -f "cinnamon --replace"

 

References:
https://askubuntu.com/questions/143838/how-do-i-restart-cinnamon-from-the-tty

 

SSH Tunneling on Linux and Mac

Do you need to tunnel to another machine frequently?

Would you like an App to save time and make it more user friendly?

Well, good news!

There’s a solution for Linux and Apple machines.

For Linux you can try Gnome SSH Manager.

From their website:

gSTM is a front-end for managing SSH-tunneled port redirects. It stores tunnel configurations in a simple XML format. The tunnels (local, remote and dynamic) can be managed and individually started/stopped through one simple interface.

https://sourceforge.net/projects/gstm/

 

Another option for Linux is IOSSHy.

From their website:

IOSSHy provides an easy to use desktop tool to quickly create and destroy SSH tunnels and launch commands based on a preconfigured setup.

Password are stored in the keyring provided by the operating system (ES: gnome’s keyring, kde’s kwallet, osx keychain, etc…)

https://www.linux-apps.com/content/show.php/IOSSHy?content=119689

 

For MacOS (OSX) it’s called Tunnel Manager.

From their website:

SSH Tunnel Manager is a macOS application to manage your SSH tunnels. If you don’t know what that is, quite honestly, maybe you don’t need SSH Tunnel Manager, but if you appreciate the power of connecting together two networks using the SSH protocol, then STM is for you.

https://www.tynsoe.org/v2/stm/

 

Did you know: SSH Tunneling is also commonly referred to as LocalForwarding, RemoteForwarding, Local Port Forwarding, Remote Port Forwarding.

 

Debian Unattended Security Updates

Follow these instructions and set your email to receive notifications.

https://wiki.debian.org/UnattendedUpgrades

apt-get install unattended-upgrades apt-listchanges

nano /etc/apt/apt.conf.d/50unattended-upgrades

Set your email to receive notificaitons:
Unattended
-Upgrade::Mail "your@email.com";

To activate unattended-upgrades, you need to ensure that the apt configuration stub /etc/apt/apt.conf.d/20auto-upgrades contains at least the following lines:

  • nano /etc/apt/apt.conf.d/20auto-upgrades
    APT::Periodic::Update-Package-Lists "1";
    APT::Periodic::Unattended-Upgrade "1";
    dpkg-reconfigure -plow unattended-upgrades

 

Alternatively, you can also create the apt configuration file /etc/apt/apt.conf.d/02periodic to activate unattended-upgrades:

  • nano /etc/apt/apt.conf.d/02periodic
    
    

     

    Below is an example /etc/apt/apt.conf.d/02periodic:

    • // Control parameters for cron jobs by /etc/cron.daily/apt-compat //
      
      
      // Enable the update/upgrade script (0=disable)
      APT::Periodic::Enable "1";
      
      
      // Do "apt-get update" automatically every n-days (0=disable)
      APT::Periodic::Update-Package-Lists "1";
      
      
      // Do "apt-get upgrade --download-only" every n-days (0=disable)
      APT::Periodic::Download-Upgradeable-Packages "1";
      
      
      // Run the "unattended-upgrade" security upgrade script
      // every n-days (0=disabled)
      // Requires the package "unattended-upgrades" and will write
      // a log in /var/log/unattended-upgrades
      APT::Periodic::Unattended-Upgrade "1";
      
      
      // Do "apt-get autoclean" every n-days (0=disable)
      APT::Periodic::AutocleanInterval "21";
      
      
      // Send report mail to root
      //     0:  no report             (or null string)
      //     1:  progress report       (actually any string)
      //     2:  + command outputs     (remove -qq, remove 2>/dev/null, add -d)
      //     3:  + trace on
      APT::Periodic::Verbose "2";
      
      Unattended-Upgrade::Mail "your@email.com";
      
      

       

Using unattended-upgrades on Debian and Ubuntu