Archive

Posts Tagged ‘HowTo’

Fix: Notification ‘Not enough system resources’ on Foscam NVR

If you try to playback recorded video via a Foscam NVR, you may get the message ‘Not enough system resources’ on screen.

Foscam suggests that this occurs on 4-screen configurations and that you have to double-click one of them to see the respective channel’s recorded video.

https://www.foscam.eu/faq/article/notification-not-enough-system-resources

However, it didn’t work when I tried it (that Foscam NVR hadn’t been recently firmware updated though, so that might have been the cause.

An alternative that did work was to download and use the free Foscam VMS software to do playback. Seems access via web browser can also be enabled on the NVR so that might also be an alternative. All methods of playback (including trying to play from the NVR itself if a screen is already attached) are explained at:

https://www.foscam.com/faqs/view.html?id=78

One can also opt to download videos from the NVR either via a computer, or to a USB storage device connected to the NVR, as shown at:

https://www.foscam.com/Faqs/view/id/79.html

Categories: Posts Tags: , , , , , , ,

HowTo: URL rewrite to redirect HTTP to HTTPS for non-local address

Below is an answer on how to redirect from HTTP to HTTPS using the URL Rewrite module for IIS, but ignoring local addresses used when debugging one’s app. Just contributed at https://stackoverflow.com/a/75898224/903783.

Needed it for an ASP.net MVC app I’m maintaining, since due to updated policy that the authenticating organisation had decided for the SSO (Apereo CAS) configuration, we couldn’t redirect anymore back to a non-HTTPs URL (had the user used plain HTTP to access our app that is), after signing in succesfully via the SSO.

Combined URL Rewrite based answers from How to redirect HTTP to HTTPS in MVC application (IIS7.5) and from the question’s page on StackOverflow, and added "127.0.0.1" apart from “localhost” for the ignored sites.

Note that the URL Rewrite approach is by far the simplest one to add and should kick in at the web server level before the web app has any chance to process the request.

I also see {REQUEST_URI} being used instead of {R:1} and pattern="^OFF$" instead of pattern="off".

At pattern added the ignoreCase="true" too, though it might be the default (same goes for enabled="true" for the rule, handy to have there if you want to turn some rule off when debugging some rule chain)

However, wondering based on https://serverfault.com/questions/224039/iis-url-rewrite-http-to-https-with-port/418530#418530 if one needs to use SERVER_NAME instead of HTTP_HOST in the pattern if non-default ports are used and specify the port in the Redirect url too

  <system.webServer>

  <!-- … -->

    <rewrite>
        <rules>

            <rule name="HTTP to HTTPS redirect (excluding localhost)" enabled="true" 
stopProcessing="true"> <match url="(.*)" /> <conditions> <add input="{HTTPS}" pattern="off" ignoreCase="true" /> <add input="{HTTP_HOST}" pattern="localhost" negate="true" /> <add input="{HTTP_HOST}" pattern="127.0.0.1" negate="true" /> </conditions> <action type="Redirect" redirectType="Permanent"
url="https://{HTTP_HOST}/{R:1}" /> </rule> </rules> </rewrite> <!-- … --> </system.webServer>
Categories: Posts Tags: , , , , , , , , ,

HowTo: HTTPS on IIS website with free auto-renewing certificate

Below is an image-based walk-through on how to configure HTTPS on an IIS website, making use of a free certificate for encryption from the non-profit Let’s Encrypt certificate authority, also configuring autorenewal of the certificate.

1) Download the win-acme client application (for the command-line).

Screenshot 2021-12-30 025002

There’s also a GUI app called IIS Crypto if you prefer. However, this article uses win-acme tool.

Screenshot 2021-12-30 025102

2) Run wacs.exe from the folder where win-acme tool is unpacked.

Screenshot 2021-12-30 025131

3) Follow same steps as below selecting your own site and binding.

Screenshot 2021-12-30 025153

Screenshot 2021-12-30 025230

Screenshot 2021-12-30 025317

Screenshot 2021-12-30 025341

Screenshot 2021-12-30 025415

Screenshot 2021-12-30 025547

Screenshot 2021-12-30 025643

Just press Q when finished and you’re done. No need to worry about next renewal (mentioned on the screen), will be done automatically.

HowTo: Use Silverlight-enabled website in Microsoft Edge Chromium

Let’s see how we can use a Silverlight-enabled website in Microsoft Edge Chromium

1) When we visit the site we’ll see a “Click now to install” button that used to download and install Silverlight, but that recently stopped working. Even before though, it wouldn’t work with Edge Chromium after installation, but show everytime the same download prompt

Screenshot (1)

2) Press “…” button at top-right and select “Settings”

Screenshot (2)

3) Pick Appearance at the left sidebar and scroll down on the right to “Internet Explrorer mode button”. If the switch to turn it on is disabled (grayed out), then press the link “allow sites to be reloaded in Internet Explorer mode”

Screenshot (5)

4) This will take you to edge://settings/defaultBrowser, where you should change “Allow sites to be reloaded in Internet Explorer mode” from “Default” to “Allow”. After that press the “Restart” button shown.

Screenshot (9)

5) Now if you go back to Appearance, you can turn on the “Internet Explorer mode button” option

Screenshot (10)

6) Now if you go back to the website, you’ll see a button at top-right allowing you to open the page in Internet Explorer mode. The same action is also available on the “…” menu, but having it as a button too can prove handy.

Screenshot (12)

7) If Microsoft hadn’t broken the direct Silverlight download links, then from this point you would be set and could use the respective website by first installing the Silverlight ActiveX control. But instead you’ll get:

Screenshot (17)

8) Luckily archive.org has cached the last Silverlight releases (you can also check them on virustotal.com after downloading if you wish) and hope they will keep them, since they’re the most trustworthy alternative source for those installers (after Microsoft of course). Ignore the “Developer” versions and just get the x86 (Silverlight.exe) or x64 (Silverlight_x64.exe) version, depending on your Windows installation

Screenshot (24)

9) Since they keep various versions archived, make sure you get the latest available one from there (don’t bother trying newer dates than 13 Oct 2021 though).

Screenshot (22)

10) After the download completes you will be able to run the downloaded installer

Screenshot (23)

11) When the installer starts, uncheck the options “Make Bing my search engine” and “Make MSN my homepage” if you don’t wish to do those actions. Then press Install now and after it downloads and installs, select “Enable Microsoft Update” (as recommended) and press Next and then Close.

Screenshot (26)

Screenshot (27)Screenshot (28)

Screenshot (29)

12) Now if you visit the Silverlight-based website again you will see the Download Silverlight prompt, but if you press the “IE mode” button on the Edge toolbar (or do the same action from the “…” menu), you’ll see the Silverlight application loading (could show some loading progress animation there or some percentage – depends on the application).

Screenshot (30)

13) You will see a popup open up where you can select that Edge should remember the current url and open it in Internet Explorer mode next time too (if you press Manage on that popup you can see those sites which are remembered for 30 days). Those sites can be managed at edge://settings/defaultBrowser

Screenshot (34)

14) after that the website opens up in Internet Explorer mode with a small warning bar at the top that you can close with the [x] button on its right

Screenshot (31)

15) And presto, you can see below ClipFlair Studio (http://studio.clipflair.net) working fine in Microsoft Edge Chromium via Internet Explorer mode and the Silverlight ActiveX Control.

Wish Microsoft wouldn’t make lives of users that hard. Not all sites are backed by multi-million dollar companies to be rewritten from scratch with HTML-based technology that still strives to support what Silverlight was offering with ease (btw, if you’d care to sponsor Clipflair Studio’s future evolutions, can donate via the respective button at https://github.com/zoomicon/clipflair)

Screenshot (32)

In the case of ClipFlair, you’ll need to do the final steps of this process for these URLs:

http://studio.clipflair.net

http://gallery.clipflair.net/activity

http://gallery.clipflair.net/video

http://gallery.clipflair.net/photo

HowTo: Reboot remote Windows computer with unresponsive RDP

I recently had an issue with an older Windows Server 2008 R2 server that couldn’t logout which had resulted to Remote Desktop not connecting to it anymore (not even with the “admin session” option). Luckily I had an admin go and physically cycle its power since it was a physial one without any lower level control available.

When the same issue occured at its twin machine, I decided before asking for another physical intervention to first try various other ways to reboot it remotely (e.g. via Windows Shutdown command and via the Computer Management console), but to no avail.

Eventually what worked was SysInternals PsShutdown tool. The syntax I used was:

PsShutdown –u AdminUserName –p AdminPassword –f –r \\MachineIPaddress

According to its command-line reference:

-u
Specifies optional user name for login to remote computer.

-p
Specifies optional password for user name. If you omit this you will be prompted to enter a hidden password.

-f
Forces all running applications to exit during the shutdown instead of giving them a chance to gracefully save their data.

-r
Reboot after shutdown.

I could maybe have used

-o
Logoff the console user.

instead of –r, but it didn’t help when I first tried without the –f option.

Guess if I had passed –f too in the first place with –o it might have worked, but it never hurts to do a reboot, unless you have any critical services you’re not sure will restart correctly. However, I would worry more about such a thing on a Unix machine rather than on a Windows one where periodic rebooting usually gives a “breath of fresh air” to the OS.

Most probably some application was preventing logoff, however I’d expect Remote Desktop / Terminal Service to be more robust in such a case.

HowTo: install multiple Corel Painter brushpacks silently

I got a nice expression software charity bundle with Corel Painter 2020 (current version is 2021) and a bunch of brushes in it and then noticed that the brush packs where available for download as separate installers than the Painter software.

So I launched one of the brush pack installers from the command-line (can give CMD and press enter at the address bar of the file explorer window to open command-line in the current folder) with a /? parameter to see its syntax:

e:\brushpack_abstract_windows.exe /?

image

Then I created a batch file to loop over all the brush_* installer files using the following commands in the console (press ENTER after each one). The for loop executes each brush pack installer from the same folder passing parameters for silent mode (/S /v/qn), as instructed by the dialog above:

copy con PainterInstallBrushes.bat
@for %%f in (brushpack_*) do %%f /S /v/qn

^Z

The last one (^Z) means Press CTRL+Z (then press ENTER for that line too). It signifies the end-of-file / input. We were inputing/copying keystrokes from the console (CON) into the file PainterInstallBrushes.bat (note that if the file exists you’re asked to overwrite it as soon as you copy the 1st line into it, but you still have to press CTRL+Z and ENTER to end input).

To avoid having to press Yes at repeated security dialogs (due to User Access Control [UAC] being activated), I opened an administrator command-prompt (can give CMD at Windows search and right click the found cmd.exe and select to open it as administrator), then executed the batch file (E: goes to drive E, CD \Corel.com goes to Corel.com folder under E: drive root)

c:\windows\system32> e:
e:\somefolder> cd \Corel.com
e:\Corel.com> PainterInstallBrushes.bat

e:\Corel.com>PainterInstallBrushes.bat

e:\Corel.com>brushpack_abstract_windows.exe /S /v/qn

e:\Corel.com>brushpack_alcoholink_windows.exe /S /v/qn

e:\Corel.com>brushpack_bristly_windows.exe /S /v/qn

e:\Corel.com>brushpack_bubbles_windows.exe /S /v/qn

e:\Corel.com>brushpack_drytexture_windows.exe /S /v/qn

e:\Corel.com>brushpack_feather_windows.exe /S /v/qn

e:\Corel.com>brushpack_fireworks_windows.exe /S /v/qn

e:\Corel.com>brushpack_gesturalillustration_windows.exe /S /v/qn

e:\Corel.com>brushpack_mangaii_windows.exe /S /v/qn

e:\Corel.com>brushpack_michellewebbmasterpack_windows.exe /S /v/qn

e:\Corel.com>brushpack_nature_windows.exe /S /v/qn

e:\Corel.com>brushpack_perfectpets_windows.exe /S /v/qn

e:\Corel.com>brushpack_popart_windows.exe /S /v/qn

e:\Corel.com>brushpack_rain_windows.exe /S /v/qn

e:\Corel.com>brushpack_rake_windows.exe /S /v/qn

e:\Corel.com>brushpack_rustandpatina_windows.exe /S /v/qn

e:\Corel.com>brushpack_scrape_windows.exe /S /v/qn

e:\Corel.com>brushpack_stipple_windows.exe /S /v/qn

e:\Corel.com>brushpack_suminagashi_windows.exe /S /v/qn

e:\Corel.com>brushpack_sunnyrays_windows.exe /S /v/qn

An alternative way to using the command-line would have been to create the batch (.bat) file with a text editor in the same folder as the brush pack installers, then right click it and select to run it as an administrator from the popup menu.

HowTo: Extract numeric suffix from a string in Python

I recently needed to extract a numeric suffix from a string value in Python. Initially I did the following:

import re

def extractNumSuffix(value):

    return (None if (search:=re.search(‘^\D*(\d+)$’, value, re.IGNORECASE)) is None else search.group(1))

Note that return has a single-line expression.

So

print(extractNumSuffix("test1030"))

prints 1030

Tried it online at:

https://repl.it/languages/python3

extractNumSuffix

However, then I found out that Assignment Expressions in Python only work from Python 3.8 and up, so I changed it to this one:

import re

def extractNumSuffix(value):
    search=re.search(r"^\D*(\d+)$", value, re.IGNORECASE)
    return (None if search is None else search.group(1))

which should work in Python 2.x too. Don’t forget to import the regular expressions (re) module.

HowTo: Install Python, PIP and cx_Oracle on MSYS2 / Windows

Here’s how to install Python, PIP package installer and cx_Oracle extension module on MSYS2:

$ pacman -S python
warning: python-3.8.3-1 is up to date — reinstalling
resolving dependencies…
looking for conflicting packages…

Packages (1) python-3.8.3-1

Total Installed Size:  108.66 MiB
Net Upgrade Size:        0.00 MiB

:: Proceed with installation? [Y/n] y

$ pacman -S cx_Oracle
error: target not found: cx_Oracle

$ pip install cx_Oracle
bash: pip: command not found

$ pacman -S python-pip
resolving dependencies…
looking for conflicting packages…

Packages (2) python-setuptools-47.1.1-1  python-pip-20.1.1-1

Total Download Size:    2.22 MiB
Total Installed Size:  10.91 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages…

$ pip install cx_Oracle
Collecting cx_Oracle
  Downloading cx_Oracle-8.0.0.tar.gz (325 kB)
     |████████████████████████████████| 325 kB 693 kB/s
Using legacy setup.py install for cx-Oracle, since package ‘wheel’ is not installed.
Installing collected packages: cx-Oracle
    Running setup.py install for cx-Oracle … error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.exe -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’; __file__=’"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’;f=getattr(tokenize, ‘"’"’open’"’"’, open)(__file__);code=f.read().replace(‘"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, __file__, ‘"’"’exec’"’"’))’ install –record /tmp/pip-record-mui2mjs9/install-record.txt –single-version-externally-managed –compile –install-headers /usr/include/python3.8/cx-Oracle
         cwd: /tmp/pip-install-wqtzv2rv/cx-Oracle/
    Complete output (17 lines):
    running install
    running build
    running build_ext
    building ‘cx_Oracle’ extension
    creating build
    creating build/temp.msys-3.1.5-x86_64-3.8
    creating build/temp.msys-3.1.5-x86_64-3.8/src
    creating build/temp.msys-3.1.5-x86_64-3.8/odpi
    creating build/temp.msys-3.1.5-x86_64-3.8/odpi/src
    x86_64-pc-msys-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -march=x86-64 -mtune=generic -O2 -pipe -DCXO_BUILD_VERSION=8.0.0 -Iodpi/include -Iodpi/src -I/usr/include/python3.8 -c src/cxoApiType.c -o build/temp.msys-3.1.5-x86_64-3.8/src/cxoApiType.o
    In file included from src/cxoModule.h:14,
                     from src/cxoApiType.c:11:
    /usr/include/python3.8/Python.h:44:10: fatal error: crypt.h: No such file or directory
       44 | #include <crypt.h>
          |          ^~~~~~~~~
    compilation terminated.
    error: command ‘x86_64-pc-msys-gcc’ failed with exit status 1
    —————————————-
ERROR: Command errored out with exit status 1: /usr/bin/python3.exe -u -c ‘import sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’; __file__=’"’"’/tmp/pip-install-wqtzv2rv/cx-Oracle/setup.py’"’"’;f=getattr(tokenize, ‘"’"’open’"’"’, open)(__file__);code=f.read().replace(‘"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, __file__, ‘"’"’exec’"’"’))’ install –record /tmp/pip-record-mui2mjs9/install-record.txt –single-version-externally-managed –compile –install-headers /usr/include/python3.8/cx-Oracle Check the logs for full command output.

Found a solution here for other Linuxes, mentioning

apt install python-dev clang libcrypt-dev

Via MSYS2 package manager (pacman), libcrypt and libcrypt-devel seem to be available. The second one should fetch the first one if needed, together with header files for development.

$ pacman -S libcrypt-devel
resolving dependencies…
looking for conflicting packages…

Packages (1) libcrypt-devel-2.1-2

Total Download Size:   0.04 MiB
Total Installed Size:  0.04 MiB

:: Proceed with installation? [Y/n] y

Now we can install cx_Oracle succesfully:

$ pip install cx_Oracle
Collecting cx_Oracle
  Using cached cx_Oracle-8.0.0.tar.gz (325 kB)
Using legacy setup.py install for cx-Oracle, since package ‘wheel’ is not installed.
Installing collected packages: cx-Oracle
    Running setup.py install for cx-Oracle … done
Successfully installed cx-Oracle-8.0.0

HowTo: make raw_input & input work the same in both Python 2 and 3

Was just trying to make a Python 2 script work in Python 3 and at first it seemed I just needed a small change to add missing parentheses to the argument of a couple of print statements.

But then another issue came up, it wasn’t understanding the command raw_input(somePrompt) that was occuring at various places in that file to input text from the console.

Various solutions were proposed at

https://stackoverflow.com/questions/954834/how-do-i-use-raw-input-in-python-3/62825723

but I think I came up with a cleaner looking solution that works in both Python2 and Python3, that should allow one to use either raw_input or input in both Python2 and Python3 with the semantics of Python2’s raw_input (aka the semantics of Python3’s input).

# raw_input isn't defined in Python3.x, whereas input wasn't behaving 
# like raw_input in Python 2.x. This should make both input and raw_input 
# work in Python 2.x/3.x like the raw_input from Python 2.x 
try: input = raw_input
except NameError: raw_input = input

In practice this came up from ideas at other answers on that SO thread. It tries to define input as raw_input which should fail in Python3.x since raw_input is undefined. In that case it will catch a NameError exception and do the reverse, aka define raw_input as input. However in Python2 the first command should execute fine, overriding the insecure input of Python2.x to work the same as raw_input (not trying to interpret input strings that is). Actually that is what Python 3.x input does.

Wonder why they didn’t declare it like that in the first place though, breaking compilation of Python2 programs. After all semantically only Python2 programs that were using the old insecure input would have an issue, not those that were using raw_input which is the semantics Python3 promotes with its newer input.

HowTo: Use DISM and SFC tools to check+fix your Windows installation

If you’re having issues with your Windows 7 or newer, you should consider whether its installation has become corrupted (due to malicious software or hard drive errors).

After doing a disk check (say by right clicking the appropriate drive under my computer and selecting Properties, then Tools tab and Error checking) and a complete virus scan (on Win10 you can click the shield icon of Windows defender in the taskbar tray and at scanning options choose to do a full scan – or if you have installed some third-party antivirus double-click its icon in the taskbar tray and when its GUI opens up opt to do a full scan), then try the following steps to repair your Windows installation:

1. Press WIN+R to open Run dialog

2. Type in:

CMD

Hold down CTRL+SHIFT keys and click OK to open the command line window in Administrator mode (do press Yes at the User Account Control prompt)

A (usually) black text-based console window will open up and you’ll be greated with something like:

Microsoft Windows [Version 10.0.18363.720]
(c) 2019 Microsoft Corporation. All rights reserved.

and then a prompt like:

C:\Windows\system32>

3. Type in the following and press the ENTER key:

DISM.exe /Online /Cleanup-image /Scanhealth

and press ENTER to execute the DISM tool with the option to check the windows image health and wait patiently for it to complete

Deployment Image Servicing and Management tool
Version: 10.0.18362.1

Image Version: 10.0.18363.720

[==========================100.0%==========================] The component store is repairable.
The operation completed successfully.

4. In case you see a message that the component store is repairable, then when greeted with the C:\Windows\system32> prompt again, type in the following and press ENTER:

DISM.exe /Online /Cleanup-image /RestoreHealth

to repair the Windows image:

Deployment Image Servicing and Management tool
Version: 10.0.18362.1

Image Version: 10.0.18363.720

[==========================100.0%==========================] The restore operation completed successfully.
The operation completed successfully.

If RestoreHealth fails and you’re on Windows 10, then you should checkout this article:

https://www.tenforums.com/tutorials/16397-repair-install-windows-10-place-upgrade.html

on how to do an in place upgrade of Windows 10, opting to keep your settings and apps

5. If all goes well you’ll see that the restore operation completed successfully and you’ll be taken again to the command-line prompt C:\Windows\system32>

Now that the windows image is checked and fine, you should check your Windows installation against that image, giving the following command and pressing ENTER:

sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection found corrupt files and successfully repaired them.
For online repairs, details are included in the CBS log file located at
windir\Logs\CBS\CBS.log. For example C:\Windows\Logs\CBS\CBS.log. For offline
repairs, details are included in the log file provided by the /OFFLOGFILE flag.

After any automatic repairs you should see the prompt C:\Windows\system32> again. Now repeat the same step till you see no more errors found and repaired.

sfc /scannow

Beginning system scan.  This process will take some time.

Beginning verification phase of system scan.
Verification 100% complete.

Windows Resource Protection did not find any integrity violations.

When back at the C:\Windows\system32> prompt with no errors found and repaired, just close the console window or type in the following and press ENTER:

exit