Showing posts with label Programming. Show all posts
Showing posts with label Programming. Show all posts

Monday, December 25, 2023

My Git cheat sheet

My Git cheat sheet

Undo changes and remove untracked files
c:\> git reset --hard HEAD
c:\> git clean -fd

Push local branch to remote
c:\> git push -u origin feature/featurename

Clone and checkout remote
c:\> git clone --branch v1.3.9 --single-branch https://github.com/open62541/open62541.git

To view the name of the head (detached like above)
c:\> git show -s --pretty=%d HEAD

Monday, January 20, 2020

Enable re-sizing of Manjaro 18.1 VirtualBox VM

I have installed Manjaro 18.1 as a VM using VirtualBox. Tried to use the default configuration using Type = Linux, Version = Arch Linux (64-bit) as Manjaro was not availabe as an option when creating a VM in VirtualBox. Unfortunately, this sets the Graphics Controller to VMSVGA which was too late for me to learn as this prevents resizing of the VM display.

Anyway, to fix this, do the following.

Update Manjaro for good measure
$: sudo pacman -Syu

If kernel is updated, restart the VM:
$: sudo reboot

Get the kernel in use as this will be needed later.
$: uname -r

Mine shows this
5.4.13-3-MANJARO

Install VirtualBox guest utils
$: sudo pacman -S virtualbox-guest-utils
At a later point it will ask for VIRTUALBOX-GUEST-MODULES, this will be the kernel guest module that needs to be installed which should match with the running kernel. For example in my VM, console output shown below, I have to select 7 as I am running kernel 5.4 (5.4.13-3-MANJARO).
resolving dependencies...
:: There are 11 providers available for VIRTUALBOX-GUEST-MODULES:
:: Repository extra
   1) linux316-virtualbox-guest-modules  2) linux414-virtualbox-guest-modules
   3) linux419-virtualbox-guest-modules  4) linux44-virtualbox-guest-modules
   5) linux49-virtualbox-guest-modules  6) linux53-virtualbox-guest-modules
   7) linux54-virtualbox-guest-modules  8) linux55-virtualbox-guest-modules
:: Repository community
   9) linux419-rt-virtualbox-guest-modules
   10) linux54-rt-virtualbox-guest-modules  11) virtualbox-guest-dkms

Enter a number (default=1): 7

Remove video driver for VMware as this is not needed anymore.
$: sudo mhwd -r pci video-vmware

Next up is to shutdown the VM as we need to change the configuration.
$: sudo shutdown -h now

Once the VM is down, change configuration Graphics Controller to VBoxVGA ( Settings | Display | Graphics Controller to VBoxVGA). Start the VM, login and resize the VM window size - should work by now. You might need to click inside the VM to force it to resize.

Reference:
https://unix.stackexchange.com/questions/499938/manjaro-guest-on-virtualbox-not-able-to-get-the-full-resolution

Sunday, January 19, 2020

Firebase getting "Uncaught TypeError: Cannot read property 'GoogleAuthProvider' of undefined at script.js:xy

I was trying to follow the documentation on "Adding Firebase to your Google Cloud project" but for the life of me I can't get the authentication to work.

Uncaught TypeError: Cannot read property 'GoogleAuthProvider' of undefined
    at script.js:31
Opening Chrome's development console and inspecting firebase.auth will also show that it is undefined.

Anyway, the fix is really easy but it was not apparent, at least for me, that I need to add the following in index.html.

<script src="https://www.gstatic.com/firebasejs/7.6.2/firebase-auth.js"></script>
Enjoy!

Wednesday, January 15, 2020

My gcloud cheat sheet


To deploy a project, change to the directory where app.yaml is located, then do:
$: gcloud app deploy

Show default project
$: gcloud config get-value project

Sunday, December 29, 2019

Roku plugin for Eclipse does not work with Eclipse 2019-12(4.14)

Eclipse 2019-12 was released last December 18, 2019. Roku plugin for Eclipse is not working yet with the latest version. I will keep this post updated as I learn more. Note that Roku plugin for Eclipse works with Eclipse 2019-09(4.13), this was tested on Ubuntu 19.10.

Reference:
https://blog.roku.com/developer/roku-eclipse-plugin
https://community.roku.com/t5/Roku-Developer-Program/Roku-plugin-for-Eclipse-not-working-using-version-2019-12/m-p/531443#M44770

Wednesday, December 18, 2019

Change git text editor in Git for Windows or cmder with Git

To change to VIM, do:

c:\> git config core.editor "vim"

Appium Windows Application Driver not working - looking for version 1.1

Installed Appium and Appium Windows Driver lately (12/18/2019) and observed that I can't get Windows application to be automated. It turns out that Appium v1.15.1 is hardcoded to check for Windows Application Driver version 1.1.

To workaround, I made changes to %appdata%\npm\node_modules\appium\node_modules\appium-windows-driver\build\lib\installer.js, in two areas:

  1. Changed to WAD_VER = '1.2'
  2. Changed to WAD_EXE_MD5 = '50d694ebfaa622ef7e4061c1bf52efe6'
See below for complete copy.

Enable Windows 10 developer mode from the command line

c:\> reg add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" /t REG_DWORD /f /v "AllowDevelopmentWithoutDevLicense" /d "1"

Reference:
https://docs.microsoft.com/en-us/windows/uwp/get-started/enable-your-device-for-development

Monday, December 16, 2019

VS Code C# for Visual Studio Code (powered by OmniSharp) plugin not finding .NET Core SDK

Running VS Code with C# for Visual Studio Code (powered by OmniSharp) plugin is complaining about the following:

The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.

This happened on my environment when I have installed dotnet-sdk using snap. To workaround, do:
$: sudo ln -sv /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet

Reference:
https://github.com/OmniSharp/omnisharp-vscode/issues/3077

Installing dotnet core SDK in Ubuntu using snap

To view currently supported version of dotnet-dsk, do:
$: sudo snap install dotnet-sdk

Installing latest stable:
$: sudo snap install dotnet-sdk

dotnet will not be available in the command line as snap creates dotnet-sdk.dotnet. Let us create an alias to make it convenient:

$: sudo snap alias dotnet-sdk.dotnet dotnet

Wednesday, December 04, 2019

Sunday, November 24, 2019

Install EF Core 3.1 Preview 3 in Ubuntu

To install Entity Framework Core 3.1.x Preview 3, do:
$: dotnet tool install --global dotnet-ef --version 3.1.0-preview3.19554.8
$: export DOTNET_ROOT=$HOME/.dotnet

Note that I am using local install of .Net Core 3.1 Preview 3 hence the need to export DOTNET_ROOT.

Install .Net Core 3.1 preview 3 in Ubuntu

$: cd ~/
$: mkdir tmp
$: cd tmp
$: wget https://dotnetwebsite.azurewebsites.net/download/dotnet-core/scripts/v1/dotnet-install.sh
$: chmod +x dotnet-install.sh
$: ./dotnet-install.sh -Version 3.1.100-preview3-014645
$: export PATH="$HOME/.dotnet:$PATH"

Saturday, November 23, 2019

Free math applications

List of free math applications:

Maxima - computer algebra system (link)
GNU Octave is a high-level language, primarily intended for numerical computations (link)
Python + scipy + matplotlib + ipython + pylab - python based numerical package (link - various )
R - a language and environment for statistical computing and graphics (link)
Sage (link)
Scilab -  is an open source, cross-platform numerical computational package and a high-level, numerically oriented programming language(link)

Sunday, November 04, 2018

UnrealEngine GenerateProjectFiles.bat error - could be due to missing RPCUtility.exe

Tried to run GenerateProjectFiles.bat to build Unreal Engine from source (link),  but got error like below:

C:\>Users\x\UnrealEngine>GenerateProjectFiles.bat
Setting up Unreal Engine 4 project files...
GenerateProjectFiles ERROR: It looks like you're missing some files that are required in order to generate projects.  Please check that you've downloaded and unpacked the engine source code, binaries, content and third-party dependencies before running this script.

To fix, run setup.bat like:

C:\Users\x\prj\UnrealEngine>setup.bat

Note that you have to say no to the prompt Would you like to overwrite your changes (y/n)?.

Saturday, April 22, 2017

Specifying port number as part of IPv6 address

Enclose IPv6 address with square brackets followed by colon and the port. For example to check if port 80 is open on 2607:f8b0:4000:811::2004, do:

c:\> psping -6 [2607:f8b0:4000:811::2004]:80

Reference(s):
http://stackoverflow.com/questions/186829/how-do-ports-work-with-ipv6

Saturday, May 07, 2016

How to view Console.WriteLine output in Xamarin Studio UI Test

To view Console.Write/Console.WriteLine output from within Xamarin Studio UI Test, do:
  1. If Unit Test pad/window is not visible, using App menu, do View | Pads | Unit Tests
  2. On a test that passed (e.g., ), select test and right click, then select Show results pad ( )

Saturday, March 26, 2016

Enable logging of .Net assembly binding via registry

You have a .Net application that fails to load and you are suspecting that it may have to do with assembly dependencies. On a development machine fuslogvw.exe will aid you in collecting failed assembly binding but fuslogvw.exe is not normally available on production environment. So what do you do?

Logging of assembly binding can be enabled via the Registry, to do so navigate to HKLM\Software\Microsoft\Fusion. Add the following keys with corresponding values:

Key
Type
Value
ForceLog
DWORD
1
LogFailures
DWORD
1
LogResourceBinds
DWORD
1
LogPath
String
C:\FusionLog\









You need to restart the .Net application under test for this to take effect. The log files will be saved in C:\FusionLog.

Reference(s):
http://stackoverflow.com/questions/1012252/using-fuslogvw-exe-on-a-machine-with-no-visual-studio-installed


Saturday, January 30, 2016

Read 64-bit remote registry from a 32-bit process in IronPython

Sample IronPython code to read remote 64-bit registry from a 32-bit process. Note that this can also be vice versa.
Reference(s):
https://github.com/haru-a8n/CodeSamples/blob/master/python/ipy/registry/readdword.py

Thursday, December 31, 2015

Generating OPC Automation IDL, TLB and header files from OPCDAAuto.dll

OPC Automation IDL, TLB and header files are not easy to find. You can obtain this files from OPC Foundation if you are a member or maybe from OPC application vendor.

The IDL file can be reverse engineered using OLE-Com Object Viewer. Once the IDL is generated TLB and other files can be generated from it as well. Below is a general direction how to do this.

Steps to reverse generate IDL, TLB and header files for OPCDAAuto.dll:

  1. Download Windows 7 SDK. I am using GRMSDKX_EN_DVD.iso as the OS is Windows 7 64-bit.
  2. Install the SDK.
  3. Open CMD Shell (Start | All Programs | Microsoft Windows SDK v7.0 | CMD Shell)
  4. Change directory to bin folder.
  5. Run oleview.exe, this will open a 32-bit version of the application. Note that this is important as the OPCDAAuto.dll I have is 32-bit as well.
  6. Navigate to Type Libraries | OPC Automation 2.0 (Ver 1.0)
  7. Double click to view Type Library definition.
  8. Do File | Save As... to D:\OPCDaAuto\OPCDaAuto.IDL.
  9. Go back to the cmd.exe as per step 3. Change directory to D:\OPCDaAuto.
  10. Fix OPCDaAuto.IDL
    1. Compile the IDL file, like, midl /win32 OPCDaAuto.IDL /header OPCDaAuto.h 
    2. This will fail about OPCGroups type specification.
    3. Fix this by moving OPCGroups definition in line 188-195 to line 104, this is above OPC Server Object. Save the file, this will change the numbering.
    4. Compile again as per sub-step 1 above.
    5. This will fail again about single type specification. Change single to float for the lines as per the output of the compilation.
    6. Compile again. This time it will complain about OPCGroup type specification.
    7. Fix this by moving OPCGroup around line 255-262 to around line 196. This above definition of Collection of OPC Group Objects.
    8. Compile again. This will fail again for another single data type. Convert it to float in 2 more places. Line location should be indicated in the compilation output.
    9. Compile again. This time it should be successful.
Note that I haven't used the corresponding TLB and header files, yet. I am hoping it will work.

Formatting code in Blogger

I have been using Github gists to share code and I have no plan of abandoning it. For smaller/one liners, I sometimes use div element with ...