Posts

Sitecore 10 common error

  {"The Sitecore layout service returned an item not found response."} {"The Sitecore layout service returned a response in an invalid format."} These two type error occurred  when your docker instance is unhealthy. You need to restart docker container either from windows tray or through ps commands.

#Powershell script | items created/updated by user in sitecore last n number of days

  The below script helps you to get all items created/updated by you in last n number of days.   Open PowerShell ISE in sitecore and run this with admin privilege ( Your user must be administrator)   $path ="master:/sitecore/content/" $items = Get-ChildItem -Path $path -Recurse |             Where-Object { $_.__Updated -gt [datetime]::Now.AddDays( -100 ) -and $_."__Updated By" -eq " sitecore\abc " }   ForEach ($item in $items) {     Write-Host $item.ID $item.Paths.Path }   PS: -100 will give you item updated in last 100 days

Sitecore 10 Installation on Docker

Image
  Sitecore is providing support on Dockers container officially now with the new release sitecore 10. This enables organizations to switch over Dockers Container for the development and production. Documentation is now available for the Sitecore Experience Platform 10.0 release: Sitecore XP 10.0 for developers and IT pros Sitecore XP 10.0 for business users Download Sitecore Experience Platform 10.0 and related assets from the   Downloads Portal . Sitecore 10 installation: Prerequisites Software Requirements 1.       Windows 10 1809 or later 2.       Windows Server 1809 or later 3.       Docker Desktop for Windows 4.       Container deployment package from sitecore.      Hardware Requirements 1.       Sitecore recommends 32 GB of RAM on Developers machine. This can be installed on 16 GB RAM machine...

DotNet | c# | This site can't be reached localhost refused to connect

Sometime we get errors on local machine like This site can't be reached localhost refused to connect   This is because of self signed certificate configuration broken for local IIS Express or  you have never configured self signed certificates on this machine ever. To fix self-signed certificate on the local machine you need to:  --> Close Visual Studio 2017 --> Delete .vs folder from the root location  (Don't worry it will be recreated) --> Run this below command in command prompt(as Administrator): cd "C:\Program Files (x86)\IIS Express" IisExpressAdminCmd.exe setupsslUrl -url:https://localhost:44342/ -UseSelfSigned --> Run VS2017 as Administrator and execute by F5 Note: https://localhost:44342/ is what is in MVC project settings under build Tab.

#Powershell | #Sitecore | Find a string phrase in the entire content tree.

 $startPath = "master:/sitecore/content/" Write-Host "Search started $(Get-Date -format 'u')"   $list = [System.Collections.ArrayList]@() $itemsToProcess = Get-ChildItem $startPath -Language * -Recurse     if($itemsToProcess -ne $null) {     $itemsToProcess | ForEach-Object {          foreach($field in $_.Fields) {             if($field.Type -eq "Single-Line Text" -or $field.Type -eq "Rich Text" -or $field.Type -eq "General Link") {                 if($field -match '//www.abc.com') {                     $info = [PSCustomObject]@{ "ID"=$_.ID     "FieldID"=$field.ID "FieldName"=$field.Name "FieldType"=$field.Type "FieldValue"=$field }                     [void]$list.Add($info)             ...

Powershell | Sitecore | Update another field value from previous field value

$rootItem = Get-Item master:/content/Item1;  // Any item starting path $ImagesourceTemplate = Get-Item "/sitecore/templates/Project/Presentation Templates/Article with Image"; // Template path Get-ChildItem $rootItem.FullPath -Recurse | Where-Object { $_.TemplateName -eq $ImagesourceTemplate.Name } | ForEach-Object {          $_.Editing.BeginEdit()         $titlefieldValue = $_.Fields["Title"].Value         $_.Fields["ShortHeadline"].Value = $titlefieldValue;         $_.Editing.EndEdit() } // This script will be updating all child items short headline field value from Title field value.

Program on deque that implements a linked list.

Program on deque that implements a linked list. #include " " #include " " #include " " struct node { int data ; struct node *link ; } ; struct dqueue { struct node *front ; struct node *rear ; } ; void initdqueue ( struct dqueue * ) ; void addqatend ( struct dqueue *, int item ) ; void addqatbeg ( struct dqueue *, int item ) ; int delqatbeg ( struct dqueue * ) ; int delqatend ( struct dqueue * ) ; void display ( struct dqueue ) ; int count ( struct dqueue ) ; void deldqueue ( struct dqueue * ) ; void main( ) { struct dqueue dq ; int i, n ; clrscr( ) ; initdqueue ( &dq ) ; addqatend ( &dq, 11 ) ; addqatbeg ( &dq, 10 ) ; addqatend ( &dq, 12 ) ; addqatbeg ( &dq, 9 ) ; addqatend ( &dq, 13 ) ; addqatbeg ( &dq, 8 ) ; addqatend ( &dq, 14 ) ; addqatbeg ( &dq, 7 ) ; display ( dq ) ; n = count ( dq ) ; printf ( "\nTotal elements: %d", n ) ; ...

Program to find the shortest path

Program to find the shortest path #include " " #include " " #define INF 9999 void main( ) { int arr[4][4] ; int cost[4][4] = { 7, 5, 0, 0, 7, 0, 0, 2, 0, 3, 0, 0, 4, 0, 1, 0 } ; int i, j, k, n = 4 ; clrscr( ) ; for ( i = 0 ; i { for ( j = 0; j { if ( cost[i][j] == 0 ) arr[i][j] = INF ; else arr[i][j] = cost[i][j] ; } } printf ( "Adjacency matrix of cost of edges:\n" ) ; for ( i = 0 ; i { for ( j = 0; j printf ( "%d\t", arr[i][j] ) ; printf ( "\n" ) ; } for ( k = 0 ; k { for ( i = 0 ; i { for ( j = 0 ; j { if ( arr[i][j] > arr[i][k] + arr[k][j] ) arr[i][j] = arr[i][k] + arr[k][j]; ...

minimum cost of a spanning tree.

minimum cost of a spanning tree. #include "stdio.h" #include "conio.h" #include "alloc.h" struct lledge { int v1, v2 ; float cost ; struct lledge *next ; } ; int stree[5] ; int count[5] ; int mincost ; struct lledge * kminstree ( struct lledge *, int ) ; int getrval ( int ) ; void combine ( int, int ) ; void del ( struct lledge * ) ; void main( ) { struct lledge *temp, *root ; int i ; clrscr( ) ; root = ( struct lledge * ) malloc ( sizeof ( struct lledge ) ) ; root -> v1 = 4 ; root -> v2 = 3 ; root -> cost = 1 ; temp = root -> next = ( struct lledge * ) malloc ( sizeof ( struct lledge ) ) ; temp -> v1 = 4 ; temp -> v2 = 2 ; temp -> cost = 2 ; temp -> next = ( struct lledge * ) malloc ( sizeof ( struct lledge ) ) ; temp = temp -> next ; temp -> v1 = 3 ; temp -> v2 = 2 ; temp -> cost = 3 ; temp -> next = ( struct lledge * ) malloc ( sizeof ...

Breadth first search algorithm.

Breadth first search algorithm. #include "stdio.h" #include "conio.h" #include "alloc.h" #define TRUE 1 #define FALSE 0 #define MAX 8 struct node { int data ; struct node *next ; } ; int visited[MAX] ; int q[8] ; int front, rear ; void bfs ( int, struct node ** ) ; struct node * getnode_write ( int ) ; void addqueue ( int ) ; int deletequeue( ) ; int isempty( ) ; void del ( struct node * ) ; void main( ) { struct node *arr[MAX] ; struct node *v1, *v2, *v3, *v4 ; int i ; clrscr( ) ; v1 = getnode_write ( 2 ) ; arr[0] = v1 ; v1 -> next = v2 = getnode_write ( 3 ) ; v2 -> next = NULL ; v1 = getnode_write ( 1 ) ; arr[1] = v1 ; v1 -> next = v2 = getnode_write ( 4 ) ; v2 -> next = v3 = getnode_write ( 5 ) ; v3 -> next = NULL ; v1 = getnode_write ( 1 ) ; arr[2] = v1 ; v1 -> next = v2 = getnode_write ( 6 ) ; v2 -> next = v3 = getnode_write ( 7 ) ; v3 -> next = NUL...

depth first search algorithm.

depth first search algorithm. #include "stdio.h" #include "conio.h" #include "alloc.h" #define TRUE 1 #define FALSE 0 #define MAX 8 struct node { int data ; struct node *next ; } ; int visited[MAX] ; void dfs ( int, struct node ** ) ; struct node * getnode_write ( int ) ; void del ( struct node * ) ; void main( ) { struct node *arr[MAX] ; struct node *v1, *v2, *v3, *v4 ; int i ; clrscr( ) ; v1 = getnode_write ( 2 ) ; arr[0] = v1 ; v1 -> next = v2 = getnode_write ( 3 ) ; v2 -> next = NULL ; v1 = getnode_write ( 1 ) ; arr[1] = v1 ; v1 -> next = v2 = getnode_write ( 4 ) ; v2 -> next = v3 = getnode_write ( 5 ) ; v3 -> next = NULL ; v1 = getnode_write ( 1 ) ; arr[2] = v1 ; v1 -> next = v2 = getnode_write ( 6 ) ; v2 -> next = v3 = getnode_write ( 7 ) ; v3 -> next = NULL ; v1 = getnode_write ( 2 ) ; arr[3] = v1 ; v1 -> next = v2 = getnode_write ( 8 ) ; v2 -> next...

Program that creates random numbers in a given file

Program that creates random numbers in a given file. #include "stdio.h" #include "conio.h" #include "stdlib.h" void main( ) { FILE *fp ; char str [ 67 ] ; int i, noofr, j ; clrscr( ) ; printf ( "Enter file name: " ) ; scanf ( "%s", str ) ; printf ( "Enter number of records: " ) ; scanf ( "%d", &noofr ) ; fp = fopen ( str, "wb" ) ; if ( fp == NULL ) { printf ( "Unable to create file." ) ; getch( ) ; exit ( 0 ) ; } randomize( ) ; for ( i = 0 ; i { j = random ( 1000 ) ; fwrite ( &j, sizeof ( int ), 1, fp ) ; printf ( "%d\t", j ) ; } fclose ( fp ) ; printf ( "\nFile is created. \nPress any key to continue." ) ; getch( ) ; }

External Sorting.

External Sorting. #include "stdio.h" #include "conio.h" #include "stdlib.h" void shownums ( char * ) ; void split ( char * ) ; void sort ( char * ) ; void main( ) { char str[67] ; clrscr( ) ; printf ( "Enter file name: " ) ; scanf ( "%s", str ) ; printf ( "Numbers before sorting:\n" ) ; shownums ( str ) ; split ( str ) ; sort ( str ) ; printf ( "\nNumbers after sorting:\n" ) ; shownums ( str ) ; getch( ) ; } /* Displays the contents of file */ void shownums ( char *p ) { FILE *fp ; int i ; fp = fopen ( p, "rb" ) ; if ( fp == NULL ) { printf ( "Unable to open file." ) ; getch( ) ; exit ( 0 ) ; } while ( fread ( &i, sizeof ( int ), 1, fp ) != 0 ) printf ( "%d \t", i ) ; fclose ( fp ) ; } /* Splits the original file into two files */ void split ( char *p ) { FILE *fs, *ft ; ...

Merge Sort.

Merge Sort. #include #include void main( ) { int a[5] = { 11, 2, 9, 13, 57 } ; int b[5] = { 25, 17, 1, 90, 3 } ; int c[10] ; int i, j, k, temp ; clrscr( ) ; printf ( "Merge sort.\n" ) ; printf ( "\nFirst array:\n" ) ; for ( i = 0 ; i printf ( "%d\t", a[i] ) ; printf ( "\n\nSecond array:\n" ) ; for ( i = 0 ; i printf ( "%d\t", b[i] ) ; for ( i = 0 ; i { for ( j = i + 1 ; j { if ( a[i] > a[j] ) { temp = a[i] ; a[i] = a[j] ; a[j] = temp ; } if ( b[i] > b[j] ) { temp = b[i] ; b[i] = b[j] ; b[j] = temp ; } } } for ( i = j = k = 0 ; i { if ( a[j] c[i++] = a[j++] ; else c[i++] = b[k++] ; if ( j == 5 || k == 5 ) brea...

Heap Sort.

Heap Sort. #include "stdio.h" #include "conio.h" void makeheap ( int [ ], int ) ; void heapsort ( int [ ], int ) ; void main( ) { int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ; int i ; clrscr( ) ; printf ( "Heap Sort.\n" ) ; makeheap ( arr, 10 ) ; printf ( "\nBefore Sorting:\n" ) ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; heapsort ( arr, 10 ) ; printf ( "\nAfter Sorting:\n" ) ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; getch( ); } void makeheap ( int x[ ], int n ) { int i, val, s, f ; for ( i = 1 ; i { val = x[i] ; s = i ; f = ( s - 1 ) / 2 ; while ( s > 0 && x[f] { x[s] = x[f] ; s = f ; f = ( s - 1 ) / 2 ; } x[s] = val ; } } void heapsort ( int x[ ], int n ) { int i, s, f, ivalue ; for ( i = n - 1 ; i > 0 ; i-- ) ...

Binary Tree Sorting.

Binary Tree Sorting. #include "stdio.h" #include "conio.h" #include "alloc.h" struct btreenode { struct btreenode *leftchild ; int data ; struct btreenode *rightchild ; } ; void insert ( struct btreenode **, int ) ; void inorder ( struct btreenode * ) ; void main( ) { struct btreenode *bt ; int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ; int i ; bt = NULL ; clrscr( ) ; printf ( "Binary tree sort.\n" ) ; printf ( "\nArray:\n" ) ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; for ( i = 0 ; i insert ( &bt, arr[i] ) ; printf ( "\nIn-order traversal of binary tree:\n" ) ; inorder ( bt ) ; getch( ) ; } void insert ( struct btreenode **sr, int num ) { if ( *sr == NULL ) { *sr = malloc ( sizeof ( struct btreenode ) ) ; ( *sr ) -> leftchild = NULL ; ( *sr ) -> data = num ; ( *sr ) -> rightchi...

Insertion sort.

Insertion sort. #include "stdio.h" #include "conio.h" void main( ) { int arr[5] = { 25, 17, 31, 13, 2 } ; int i, j, k, temp ; clrscr( ) ; printf ( "Insertion sort.\n" ) ; printf ( "\nArray before sorting:\n") ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; for ( i = 1 ; i { for ( j = 0 ; j { if ( arr[j] > arr[i] ) { temp = arr[j] ; arr[j] = arr[i] ; for ( k = i ; k > j ; k-- ) arr[k] = arr[k - 1] ; arr[k + 1] = temp ; } } } printf ( "\n\nArray after sorting:\n") ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; getch( ) ; }

Quick sort

Quick sort #include "conio.h " #include "stdio.h " int split ( int*, int, int ) ; void main( ) { int arr[10] = { 11, 2, 9, 13, 57, 25, 17, 1, 90, 3 } ; int i ; void quicksort ( int *, int, int ) ; clrscr( ) ; printf ( "Quick sort.\n" ) ; printf ( "\nArray before sorting:\n") ; for ( i = 0 ; i lower ) { i = split ( a, lower, upper ) ; quicksort ( a, lower, i - 1 ) ; quicksort ( a, i + 1, upper ) ; } } int split ( int a[ ], int lower, int upper ) { int i, p, q, t ; p = lower + 1 ; q = upper ; i = a[lower] ; while ( q >= p ) { while ( a[p] i ) q-- ; if ( q > p ) { t = a[p] ; a[p] = a[q] ; a[q] = t ; } } t = a[lower] ; a[lower] = a[q] ; a[q] = t ; return q ; }

Selection sort.

Selection sort. #include " " #include " " void main( ) { int arr[5] = { 25, 17, 31, 13, 2 } ; int i, j, temp ; clrscr( ) ; printf ( "Selection sort.\n" ) ; printf ( "\nArray before sorting:\n") ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; for ( i = 0 ; i { for ( j = i + 1 ; j { if ( arr[i] > arr[j] ) { temp = arr[i] ; arr[i] = arr[j] ; arr[j] = temp ; } } } printf ( "\n\nArray after sorting:\n") ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; getch( ) ; }

Bubble sort.

Bubble sort. #include #include void main( ) { int arr[5] = { 25, 17, 31, 13, 2 } ; int i, j, temp ; clrscr( ) ; printf ( "Bubble sort.\n" ) ; printf ( "\nArray before sorting:\n") ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; for ( i = 0 ; i { for ( j = 0 ; j { if ( arr[j] > arr[j + 1] ) { temp = arr[j] ; arr[j] = arr[j + 1] ; arr[j + 1] = temp ; } } } printf ( "\n\nArray after sorting:\n") ; for ( i = 0 ; i printf ( "%d\t", arr[i] ) ; getch( ) ; }