PowerShell Script to Prevent Your Machine From Logging You Out or Sleeping While You Do Other Things

In certain environments, my development machine does not have access to the interwebs. I have to use a separate machine that is connected to the outside world to lookup a snippet or research a deeper issue. If I don’t think to tap the space bar at least every four minutes and 59 seconds, I have to re-authenticate to continue development. Then those dozen or so characters I’ve had to memorize interrupt me (Squirrel!) from the issue at hand; worse if I fat-finger the input. So here is a PowerShell script that does the mindless key tapping for me:

param($numKeyTaps = 90)
$wsShell = New-Object -com "Wscript.Shell"
for ($i = 0; $i -lt $numKeyTaps; $i++) {
Start-Sleep -Seconds 360
$wsShell.sendkeys("{NUMLOCK}")
Write-Host "Tapped Numlock key"
}

Notes on Moving Meteor Development to WSL Debian

https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

Turn Windows Features on and off, scroll down and check Windows Subsystem for Linux

Click on OK, and WSL will install. You’ll need to reboot to enable it.

From there, go to the Windows Store and choose your preferred Linux distribution. I used Debian.

Click on Get, install the distribution, and if you want, launch the terminal from the Start menu Debian Icon.

I use CMDR (https://cmder.net). It is superior to the default WSL Bash terminal and Windows Terminal for WSL support, multiple tabs and better character support. You’ll need the multiple tabs to run meteor and meteor mongo simultaneously.

Open up a CMDR WSL Bash terminal. You are in the home/user folder.

Update:
sudo apt update

Install curl
sudo apt-get install curl

Install Meteor
curl https://install.meteor.com/ | sh

Install MongoDB Tools, allows you to bulk import json data
sudo apt-get install mongo-tools

Install git
sudo apt-get install git

Create a Meteor app
meteor create –react ~/myapp
cd ~/myapp
meteor

Open a new WSL tab
meteor mongo

If you get an error like:
WSL Error:
Retrying after error { Error: SQLITE_IOERR: disk I/O error
=> awaited here:
at Promise.await
(/home/debian/.meteor/packages/meteor-tool/.1.8.1.ani1yi.p0f9s++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/dev_bundle/lib/node_modules/meteor-promise/promise_server.js:60:12)
at Db._execute (/tools/packaging/catalog/catalog-remote.js:347:15)

You will need to:
vi .meteor/packages/meteor-tool/.1.8.1.ani1yi.p0f9s++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js

Find:
self._execute(`PRAGMA journal_mode=${JOURNAL_MODE}`);
Replace with:
self._execute(`PRAGMA journal_mode=TRUNCATE`);
Exit and Save (ESC :wq ENTER)

If you had to sudo vi running meteor may error with permission denied. So youmay need to:
chmod +rw .meteor/packages/meteor-tool/.1.8.1.ani1yi.p0f9s++os.linux.x86_64+web.browser+web.browser.legacy+web.cordova/mt-os.linux.x86_64/tools/packaging/catalog/catalog-remote.js

All of that should allow you to open multiple tabs while running meteor. Run meteor in the first tab then in the second tab import your data:
mongoimport -h localhost:3001 –db meteor –collection mydata –type json –file “./.db-json/mydata.json” –jsonArray

show dbs
use meteor
show collections
db.mydata.find().count()
db.mydata.find().pretty()
db.mydata.remove({}) – to delete all records

You can also:

Open explorer where you are:
explorer.exe . (that is a space and a period after the exe)

Open Visual Studio Code where you are:
code .

Other Notes:

meteor remove blaze-html-templates
meteor add angular-templates
meteor npm install –save angular angular-meteor

meteor remove static-html

meteor add accounts-password dotansimha:accounts-ui-angular
meteor npm install –save bcrypt

meteor remove insecure

meteor remove autopublish

Need to get Docker to work:

sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
manually add deb https://download.docker.com/linux/ubuntu bionic stable to software sources
sudo apt update
sudo apt-get install docker-ce docker-ce-cli containerd.io
sudo systemctl status docker
sudo docker run hello-world
sudo docker info
sudo docker version

sudo usermod -a -G docker $USER
sudo reboot

npm update caniuse-lite browserslist ???

docker build -t pipefitters .
docker run -d -p 80:3000 pipefitters
no workie

https://cloud.mongodb.com

Create Windows 10 Install USB Drive

How to create a bootable Windows 10 USB drive from the command line.

You’ll need the .ISO file for Windows 10.

Open the command prompt as the administrator, type “diskpart” without the quotes, and hit enter.

Plug in your USB drive. Type “list disk” without the quotes and hit enter. Take a look at the Size column and figure out which disk number your USB drive is.

Ours is number 1, so we’re going to type “select disk 1” without the quotes and hit enter. Adjust your disk number accordingly.

Now wipe the drive by typing in “clean” without the quotes and hitting enter.

Type “create partition primary” without the quotes and hit enter.

Then type “select partition 1” without the quotes and hit enter.

Next type “active” without the quotes and hit enter.

Finally, type “format fs=fat32” without quotes and hit enter.

When that’s done, type “assign” without the quotes and hit enter.

Mount the .ISO.

Close diskpart and open up cmd again. Type “xcopy g:*.* /s/e/f h:” without the quotes, where “g:” is the drive letter for your mounted .iso file and “h:” is the drive letter for your USB flash drive. Don’t worry if install.wim takes a while to copy: It’s easily the biggest file on the disc.

Type “exit” without the quotes and hit enter. You’re done. You can now install Windows 10 from your USB drive, either by booting from it or from within an existing installation of Windows.

Consume Volusion eStore API Using Meteor JS

The \server\main.js in this example performs an API call to your Volusion eStore, converts the response to JSON and inserts to MongoDB.

The \client\main.js makes the call and displays the data from MongoDB.

meteor create volusionapi

cd volusionapi

meteor add http peerlibrary:xml2js

Copy these files https://github.com/cjfleischhacker/MeteorVolusionAPI.git or create these files:

\client\main.html

<head>
<title>volusion</title>
</head>
<body>
<h1>Welcome to Meteor!</h1>
{{> vapi}}
</body>
<template name="vapi">
<h3>List Courses</h3>
<p style="color: #ff0000; margin: 10px 0 10px 0;">
{{errMessage}}
</p>
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Code</th>
<th>Name</th>
</tr>
</thead>
<tbody>
{{#each courses}}
<tr>
<td>{{ProductID}}</td>
<td>{{ProductCode}}</td>
<td>{{ProductName}}</td>
</tr>
{{/each}}
</tbody>
</table>
</template>

\client\main.js

import { Template } from 'meteor/templating';
import { ReactiveVar } from 'meteor/reactive-var';
import './main.html';
Courses = new Mongo.Collection('courses');

Meteor.call(‘getJSONFromAPI’, function (err, res) {
if (err) {
console.log(err);
} else {
console.log(res.xmldata.Products);
}
});

Template.vapi.onCreated(function helloOnCreated() {
console.log(‘oncreate…’);
});

Template.vapi.helpers({
courses: function () {
return Courses.find();
}
});

\server\main.js

import { Meteor } from 'meteor/meteor';
import { xml2js } from 'meteor/peerlibrary:xml2js';
Courses = new Mongo.Collection('courses');

Meteor.methods({
‘getJSONFromAPI’: function () {
this.unblock();
var apiUrl = ‘http://store.volusion.com/net/WebService.aspx?Login=email@mystore.com&EncryptedPassword=YourVolusionAPIEncryptedPassword&EDI_Name=Generic\\Products&SELECT_Columns=p.ProductCode,p.ProductName,pd.ProductDescription’

;
var response = Meteor.wrapAsync(apiCall)(apiUrl);
const result = xml2js.parseStringSync(response, { explicitArray: false, emptyTag: undefined });
for (var i = 0; i < result.xmldata.Products.length; i++) {
Courses.insert(result.xmldata.Products[i]);
}
return result;
}
});

var apiCall = function (apiUrl, callback) {
// try…catch allows you to handle errors
try {
var response = HTTP.get(apiUrl).content;
// A successful API call returns no error
callback(null, response);
} catch (error) {
// If the API responded with an error message and a payload
if (error.response) {
var errorCode = error.response.data.code;
var errorMessage = error.response.data.message;
// Otherwise use a generic error message
} else {
var errorCode = 500;
var errorMessage = ‘Cannot access the API’;
}
// Create an Error object and return it via callback
var myError = new Meteor.Error(errorCode, errorMessage);
callback(myError, null);
}
}

meteor