Zoom stuck at 70% in MS Word 365

So this little ridiculous issue has been haunting me for two days until I finally got a moment to troubleshoot it.

My Word page zoom has been stuck at 70%-something the last few days, even though I had plenty of white space (or gray space) on both sides of the document.

Turns out the page view layout was setup to use “Page-to-page” instead of “Vertical”.

No matter how hard I try to zoom out, nothing happens.

Change layout to “Vertical” and the issue is resolved!

Finally… I can read the text again.

New PC stuck in Windows 10 S mode? Here’s how to unlock it

So a colleague just bought a new PC and it came pre-installed with “Windows 10 in S mode”. This is a locked down version of Windows where you can only install apps from the app store. Regular exe files etc are blocked.

Luckily you can disable the locked down mode rather easily. However, as of today, there’s no way to reactivate it again, so keep that in mind. Your 85 y/o grandma might be better off having it enabled as it’s a good way to block potential viruses.

The annoying thing is that in order to disable S mode, you actually have to “download” or run an app from the app store, and this requires a Microsoft account. So, for those of us who likes to use a local user account instead of logging on with a Microsoft account, we still have to login in order to run the app from the Microsoft Store.

Steps for disabling Windows 10 S mode:

1: Open Settings

2: Go to Updates & Security

3: Open the Activation tab.

You will see that your current Windows edition is set to “Windows 10 X in S mode” (where X is probably Home or Pro).

4. Click on the Go to the Store button. This will open the necessary “app” you need to run in order to unlock the regular Windows mode.

5. Run the app. Login with your Microsoft account when prompted (or create a throwaway account). Your PC is now unlocked.

6. Alternative step: Install Ubuntu

Creating an email censoring filter in Vuejs

This is a neat little function you can use as a filter in Vuejs to partially censor emails so for instance myemail@example.com will show as m****l@e*********m. In other words, show the first and last letter before and after the @ delimiter.

filters: {
    censorEmail(val) {
        try {
            let arr = val.split("@");
            let wrd = arr[0][0] + "*".repeat(arr[0].length-2) + arr[0].slice(-1);
            let wrd2 = arr[1][0] + "*".repeat(arr[1].length-2) + arr[1].slice(-1);
            return wrd + "@" + wrd2;   
        } catch (error) {
            return "Not a valid email";
        }
    }
}

There’s not really any validation for a proper email address happening, we just check if the input value contains a @. If not, it simply returns “Not a valid email”.

v-model in child components

If you’re having trouble using v-model for input elements in child components then welcome to the club. Here’s a quick way to solve it by using $emit to pass data back to parent:

App.vue:

<ChildComponent 
    v-bind:myvar="myvar"
    @myfunction="myfunction"
/>

<script>
export default {
    name: "App",
    components: {
        ChildComponent,
    },
    data: function() {
        return {
            myvar: "foo"
        }
    },
    methods: {
        myfunction(val) {
            this.myvar = val;
        }
    }
};
</script>

ChildComponent.vue:

<template>
    <input :value="myvar" @input="$emit('myfunction', $event.target.value)">
</template>

<script>
export default {
    name: 'ChildComponent',
    props: {
        myvar: String,
    }
};
</script>

Idle Mobster – Simple game made in Vuejs

So to learn Vuejs I decided to make a simple idle game. You know, one of those games that kinda plays itself by upgrading stuff and increasing your income etc.

This game is inspired by the old school mafia text-based browser games, so you’ll find the usual stuff like petty crime, upgrading weapons and managing businesses.

Current state of the game is very simple and there’s no prestige system implemented yet, but I have many features planned ahead. It’s still a work in progress, but I released it on itch.io (which is also my first time so learning by doing):

The code will eventually be available at my github site (probably github.com/kek91/idle-mobster (will update this post when it’s published).

Format number in Javascript for Integer and Float types

I was stuck trying to format a Number variable when creating an output filter in Vuejs.

Originally I used

filters: {
    filterNumber(val) {
        if(typeof(val) == "number") {
            return new Intl.NumberFormat().format(val);
        }
        return val;
    }
}

That will output a number like “123456” as “123 456”. But I also want it to skip decimals. Using .toFixed(0) doesn’t work as that only accept Float variables. Casting the Intl variable to Float using parseFloat() around it didn’t work either.

The solution was to use .toLocaleString() instead, like this:

filters: {
    filterNumber(val) {
        if(typeof(val) == "number") {
            return val.toLocaleString('US', {minimumFractionDigits: 0, maximumFractionDigits: 0});
        }
        return val;
    }
}

Consuming a REST API in C# WPF

When consuming REST APIs in C# I like to use the Newtonsoft.Json library which is available as a NuGet package.

Start by adding the package to your library. Right-click on your project in the Solution Explorer (if using Visual Studio) and click on “Manage NuGet Packages…”

Search for Json and add Newtonsoft.Json.

Add a reference by typing using Newtonsoft.Json.Linq;

For connecting to the API you can use many options. To keep it simple we’ll use System.Net.WebClient. Ref example code below:

var apiUrl = "https://example.com/api/v1/helloworld";
using WebClient wc = new WebClient();
var jsondata = wc.DownloadString(apiUrl);
JArray jsonarray = JArray.Parse(jsondata);
foreach (var item in jsonarray)
{
    JObject jsonobject = JObject.Parse(item.ToString());
    Debug.WriteLine(jsonobject);
}

Another example without looping through the items and using WebClient in another way:

var apiUrl = "https://example.com/api/v1/helloworld";
using (WebClient wc = new WebClient())
{
    var jsondata = wc.DownloadString(apiUrl);
    JObject jsonobject = JObject.Parse(jsondata.ToString());
    Debug.WriteLine(jsonobject);
}

Show complete URL in Brave browser

I’m currently playing around with the Brave browser and so far I like it a lot. However I’m not fond of the trend of hiding parts of the URL which some browsers do. I prefer simply reading the URL scheme myself instead of depending on some vague SSL lock icons or whatever. Here’s a quick tutorial for showing the complete URL bar in Brave.

Open a new tab and enter brave://flags or chrome://flags (doesn’t matter which, both work since both are based on the Chromium project).

In the filter/search bar, enter “hide”, this will bring up the relevant flags you need to edit.

Change the following flags to Disabled

Omnibox UI Hide Steady-State URL Scheme
Omnibox UI Steady-State URL Trivial Subdomains
Omnibox UI Hide Steady-State URL Path, Query and Ref

You can also use the following link shortcuts:

brave://flags/#omnibox-ui-hide-steady-state-url-scheme

brave://flags/#omnibox-ui-hide-steady-state-url-trivial-subdomains

brave://flags/#omnibox-ui-hide-steady-state-url-path-query-and-ref

See image below for your reference:

Argument list too long

Apparantly this stems from a limitation in the kernel regarding the size of command arguments. The Argument list is too long error message is typically shown if you try to run a command on a large filelist (for instance targeting files in a huge directory using wildcards), because the Linux kernel will split every target file found as separate arguments.

Say you have a directory containing three files; file1.txt, file2.txt, file3.txt. Running the command rm * in this directory will actually be interpreted as rm file1.txt file2.txt file3.txt by the kernel.

Two quick solutions comes to mind.

Using a for loop:

for f in /home/itdb/deleteme/*; do rm "$f"; done

Using the find command:

find /home/itdb/deleteme -name "*" -delete

For more information, check out this stackoverflow question:
https://stackoverflow.com/questions/11289551/argument-list-too-long-error-for-rm-cp-mv-commands