Saturday, 19 June 2021

Change docker images and containers location with Windows 10


Docker with windows has 2 mode windows and linux (wsl)

  1. For Windows Mode:

    Docker Configuration File:

    By default, Docker stores Images and other configuration files In the location below:

    C:\ProgramData\Docker

    Which also mean that Images, volumes, etc will be stored in the same location.

    To change the storage location with the need to create a configuration file called Daemon.json and specify the new location.

    By default, the file doesn’t exist and we need to create under the path below:

    'C:\ProgramData\Docker\config\daemon.json'

    set data-root path

    {
    "data-root": "D:\\ProgramData\\Docker"
    }

    for old docker use graph instead of data-root

    You must stop docker service before changing daemon.js and start again after changing.

    you can also do that from GUI docker settings --> Docker Engine

  2.  For linux subsystem (wsl) mode:
    Before applying the below steps check installing Windows Subsystem for Linux (WSL).
    • Quit docker
    • Run from command prompt:
              wsl --list -v
              you will see


    • Export docker-desktop-data into a file
      wsl --export docker-desktop-data "E:\Code\DevOps\Docker\docker-desktop-data.tar"


    • Unregister docker-desktop-data from wsl
      wsl --unregister docker-desktop-data
    • Import the docker-desktop-data back to wsl but with new path
      wsl --import docker-desktop-data "E:\Code\DevOps\Docker\wsl\data" "E:\Code\DevOps\Docker\docker-desktop-data.tar" --version 2 
    • Start the Docker Desktop again and it should work

Tuesday, 4 August 2020

Run Solr as a Service on Windows

Solr 8 Prerequisites:
  1. Solr
  2. Java JDK 8+
  3. NSSM

Solr as a service
  1. Run command prompt as admin:
  2. From command prompt run
    nssm install solr8
  3. Configure service like images below:




  4. Click on Install service.
  5. Check windows services in services.msc installed and run.
  6. If service failed to start test service run from command line:
    bin/solr start
  7. Check Solr is up and running from url:


Monday, 3 August 2020

SharePoint Administration Urls

Famous urls help you administrate SharePoint site:

Site Contents
/_layouts/viewlsts.aspx
Site Settings
/_layouts/settings.aspx
Site Content and Structure Manager
/_layouts/sitemanager.aspx
Manage Site Collection Administrators
/_layouts/15/mngsiteadmin.aspx
People and Groups
/_layouts/people.aspx
Manage User Permissions
/_layouts/user.aspx
Grant Permission
/_layouts/aclinv.aspx
Check Permission
/_layouts/15/chkperm.aspx
Master Page Gallery
/_catalogs/masterpage
Web Part Gallery
/_catalogs/wp
Create a list or library
/_layouts/create.aspx
List Template Gallery
/_catalogs/lt
Manage Sites and Workspace
/_layouts/mngsubwebs.aspx
Site Collection Recycle Bin
/_layouts/AdminRecycleBin.aspx?View=stage 
stage: 1 or 2
Site Level Recycle Bin
/_layouts/RecycleBin.aspx
Site Column Gallery
/_layouts/mngfield.aspx
Site Content Types
/_layouts/mngctype.aspx
Solution Gallery
/_catalogs/solutions/
User Alerts
/_layouts/sitesubs.aspx
Web Part Page Maintenance
<Page Url>?contents=1
Manage navigation quick launch /_layouts/quiklnch.aspx
Manage Global Navigation
/_layouts/15/AreaNavigationSettings.aspx
Web analytical reports for the site /_layouts/usage.aspx
Manage the site collection/Site level features /_layouts/ManageFeatures.aspx?Scope=scopeparam
scopeparam: Site (Site), Web (Web)
Version of SharePoint server /_vti_pvt/Service.cnf
Change site master page SharePoint
/_layouts/ChangeSiteMasterPage.aspx
Audit log reports
/_layouts/15/Reporting.aspx?Category=Auditing
Storage metrics
/_layouts/15/storman.aspx
Site hierarchy
/_layouts/15/vsubwebs.aspx
Filter to the list view
<List/Library URL>?filter=1
Add App
<List/Library URL>/_layouts/15/addanapp.aspx”
App registration
/_layouts/15/appregnew.aspx
Taxonomy hidden list
/lists/taxonomyhiddenlist/allItems.aspx
Web part page edit mode
?toolpaneview=2
Save site as template
/_layouts/15/savetmpl.aspx
User information list
/_catalogs/users/detail.aspx
Master page gallery /_catalogs/masterpage/Forms/AllItems.aspx
Default page settings /_layouts/AreaWelcomePage.aspx
Page Layouts and Site Templates /_Layouts/AreaTemplateSettings.aspx
Hidden Variation Relationships List
/Relationships%20List
Hidden Variation Labels List

Variation Labels settings
_Layouts/VariationLabels.aspx
Workflow manager page /_layouts/wrkmng.aspx

SharePoint programmatically move a splistitem to another folder in the same list

My customer requests moving list items to sub folders keeping item id. Most of articles talk about moving document files instead of list items. Second problem, Moving item from GUI recreate new item with new item id.
Below code solving my problem moving item to new folder keeping the same id:

            var securePassword = new SecureString();
            foreach (char c in password)
            {
                securePassword.AppendChar(c);
            }
            using (var clientContext = new ClientContext(siteurl))
            {
                clientContext.Credentials = new SharePointOnlineCredentials(userName, securePassword); 
                Web web = clientContext.Web;
                clientContext.Load(web,a=>a.ServerRelativeUrl); 
                clientContext.ExecuteQuery();
                List list = clientContext.Web.Lists.GetByTitle(listname);
                ListItem items = list.GetItemById(itemid);
                clientContext.Load(items,item => item.Id, item => item["FileLeafRef"],item=>item["FileDirRef"],item => item["FileRef"]);
                clientContext.ExecuteQuery();
                var itemasfile = web.GetFileByServerRelativeUrl(items["FileRef"].ToString());
                //targetfolderpath sample "Lists/ListName/FolderDestination" ;
                string targetfilepath = items["FileRef"].ToString().Replace(items["FileDirRef"].ToString(), targetfolderpath);
                itemasfile.MoveTo(targetfilepath, MoveOperations.Overwrite);
                clientContext.ExecuteQuery();
            }

Sunday, 7 June 2020

python ImportError: cannot import name 'open_code' from 'io'

I faced python errors:

  1. First error:
    Fatal Python error: init_sys_streams: can't initialize sys standard streams
    Traceback (most recent call last):
      File "/home/user/miniconda3/envs/py38/lib/python3.8/io.py", line 54, in <module>
    ImportError: cannot import name 'open_code' from 'io' (unknown location)
    Aborted (core dumped)
    This error comes from the fact that there are two different versions of Python conflicting with each other.

  2. Second error:
tack Error: Command failed: E:\ProgramData\Anaconda3\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack   File "<string>", line 1
gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack                                ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack     at ChildProcess.exithandler (child_process.js:303:12)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at maybeClose (internal/child_process.js:1021:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
gyp ERR! System Windows_NT 10.0.18363

This error because it required old version of python 2.7

To solve these errors we need to install multiple versions of python and switch between them

You can use this command to install python version
nvm install v6.11.4

You can use this command to list all python versions
nvm list

You can use this command to set default version
nvm use v6.11.4




MSBUILD error

I have tried the troubleshooting steps for installing node-sass. But it did not work fine. It did not installed the node-sass and generated errors.

  E:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(390,5): error MSB8020: The build tools for Visual Studio 2017 (Platform Toolset = 'v141') cannot be found. To build using the v141 build tools, please install Visual Studio 2017 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [E:\Code\Liferay\com-liferay-commerce-7.1.x\commerce-bom-admin-web\node_modules\node-sass\build\src\libsass.vcxproj]
 
Install all the required tools and configurations using Microsoft's windows-build-tools by running:
npm install -g windows-build-tools  (install msbuild visual studio 2017)

set msbuild visual studio 2017 set as default:
npm config set msbuild_path "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe"

After that my problem was solved

Friday, 5 June 2020

CPUs are not running at its full capacity in Windows 10

Suddenly I found my CPUs are not running at its full capacity (max 30%).
I found solution Disable Intelppm registry in Registry Editor:
  1. Edit the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\intelppm\Start = 4
  2. Or Execute "sc config intelppm start= disabled"
  3. Reboot your computer.
I found this solution in the following article:

Change docker images and containers location with Windows 10

Docker with windows has 2 mode windows and linux (wsl) For Windows Mode: Docker Configuration File: By default, Docker stores Images and ot...