Wednesday, September 4, 2019

Win10: PC wake up from sleep at midnight

This problem came back recently...I suspect it's related to the recent Windows updates.

Some commands to help troubleshoot it

powercfg /lastwake
powercfg /devicequery wake_armed
powercfg /waketimers

Sunday, June 30, 2019

Aseprite: 100% zoom is bigger than actual size

Recently I started using Aseprite. One thing I noticed was my drawing in Aseprite is bigger than the actual size, even with zoom level set to 100%.

Turns out Aseprite has a screen scaling setting that is set to 200% by default.
Edit > Preferences > Screen Scaling.

However, after changing it to 100%, the Aseprite editor look too small. Thanksfully there is a UI Elements Scaling setting as well. Setting it to 200% should make it usable like before.

100% zoom is not 100% zoom?? : aseprite

Monday, April 29, 2019

UE4: Unable to start debugger in Visual Studio

I have my unreal project opened in Visual Studio. When I press F5 to start the debugger, it shows the following error message. "Unable to start program 'C:\Program Files\Epic Games\UE_4.22\Engine\Intermediate\Build\Unused\UE4.exe'."


It is because UE4 was set as the startup project. To fix it, go to the Solution Explorer in Visual Studio, then right-click on your game project > Set as StartUp Project.

Unable to start program UE4.exe error - UE4 AnswerHub

Monday, April 22, 2019

UE4: How to use the new AudioCapture component to record microphone audio

There are two functions for recording audio:
* Start Recording Output
* Start Recording Submix Output

1. Follow this quick start guide to activate the new audio engine, e.g. uncomment AudioDeviceModuleName=AudioMixerXAudio2 in WindowsEditor.ini if you're developing on Windows

2. In your blueprint, add the AudioCapture component

3. Use "Start Recording Output" to record the master output of the game. Otherwise, use "Start Recording Submix Output" to capture a particular sound source (see note #2 below).

4. If you don't specify an output path, it saves the .wav file in Saved\BouncedWavFiles

* UE4 will crash if no audio input device is connected. Probably should use the "Enumerate Audio Capture Devices" function to check for available devices before recording.

* Setting up a Submix Destination on your Sound Source

Unless otherwise set or specified, all Sound Sources output to the Master Submix (not visible on graph) by default. However, it will sometimes be desirable to have your sound source output into a different Submix.
  1. Access the details panel for your sound source
  2. Locate the Effects submenu
  3. Locate the entry called Sound Submix
    1. If this says “None,” then the sound defaults output to the Master Submix
    2. Here you can enter an alternate Submix
    3. Note the separate Default Master Reverb Send amount if you wish to simply send the source to the Master Reverb

Confused about new Audio Capture Component usage in 4.19 - Unreal Engine Forums
New Audio Engine: Early Access Quick-Start Guide - Unreal Engine Forums

Wednesday, April 3, 2019

Firefox: taking fullscreen screenshot

1. press F12 to bring up Web Developer Tools
2. press F1 to open up Settings
3. scroll down to Available Toolbox Buttons and enable Take a screenshot of the entire page
4. a camera icon would appear at the top right of the Web Developer Tools panel. By default, it saves the screenshot in your Downloads directory.

Firefox 32 for developers - Mozilla | MDN

For Chrome, see here

Friday, March 29, 2019

UE4: Reduce CPU usage of Unreal Engine Editor

Recently I started to play around with Unreal Engine. One thing I noticed was that when I have my game project open, the Unreal Engine Editor is consistently taking 20%-30% CPU power.

One simple solution is to turn off realtime rendering.
1. In the viewport, click on the triangle in upper left corner
2. Uncheck Realtime

Another solution is to limit viewport frame rate.
1. In Unreal Engine Editor, press ` key to bring up the command line prompt
2. Type t.MaxFPS 30 will limit it to 30 FPS. You can tweak this number based on your setup

Type dumpconsolecommands to view the list of available console commands has a nice article on other tips and tricks to help maximize battery life for UE4 development on laptop.

Is there a way to limit GPU usage? - UE4 AnswerHub
UE4 Console commands list - UE4 AnswerHub

Sunday, January 13, 2019

Python3: Authenticate with Discord API using urllib.request

I wanted to do some automation with Discord, so I started writing a Python script to query Discord's API. First step is to authenticate with Discord. Following the documentation, I sent a POST request to the token URL. However, I was getting a HTTP 403 with error message
"Please enable cookies. Error 1010...Access denied...The owner of this website ( has banned your access based on your browser's signature..." It appears to be protected by Cloudflare.

First thing I tried was to use http.cookiejar for my POST request, but that did not help. Following the sample code in the documentation, I switched over to requests instead of the built-in library urllib.request, and it worked! But I was curious why it did not work with urllib.request.

Then I tried Postman to send the POST request, and it worked as well. Postman has a code generation feature for http.client (Python 3). There were some errors in the generated code, but I was able to fix them and got it to work with Discord. http.client is a low-level library and used by urllib.request, so why is it working with http.client but not urllib.request?

Next, I fired up Wireshark to monitor and compare the POST requests. After bunch of trial and error, I found the answer to be rather simple.

"" (empty string) - works
"python-requests/2.21.0" - works
"Python-urllib/3.6" - does not work

It turns out Cloudflare does not like the user-agent string from urllib.request. Requests from http.client do not have an user-agent set by default, thus it worked. So for anyone who want to use urllib.request, set the user-agent to blank or match with your browser should avoid this error.