create letsencrypt exception for apache reverse proxy along with ip restrictions

Under normal circumstances, setting up an apache reverse proxy with a letsencrypt exception for /.well-known is easily done with ProxyPass /.well-known ! It seems to become much more difficult (something which I happen to have easily solved in nginx) to configure this exception along with ip restrictions for the backend:

<VirtualHost *:80>   ServerName example.com   DocumentRoot /var/www/html   Redirect / https://example.com/ </VirtualHost>  <VirtualHost *:443>   ServerName example.com    SSLEngine on   SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem   SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem   DocumentRoot /var/www/html    ErrorLog $  {APACHE_LOG_DIR}/bfp-all_error.log   CustomLog $  {APACHE_LOG_DIR}/bfp-all_access.log combined    RewriteEngine On   RewriteCond %{HTTP:Connection} Upgrade [NC]   RewriteCond %{HTTP:Upgrade} websocket [NC]   RewriteRule /(.*) ws://localhost:8050/$  1 [P,L]      ProxyRequests Off   ProxyPreserveHost On <Location />     ProxyPass "http://localhost:8050/"     ProxyPassReverse "http://localhost:8050/"     Require ip 10.0.0.0/24     Require ip 192.168.0.0/24 </Location> </VirtualHost> 

I tried using Alias and (and also the directory, which seems to be already quite redundant) before the section but the requests keep going to the backend:

DocumentRoot /var/web/letsencrypt Alias /.well-known /var/web/letsencrypt/.well-known   <Directory /var/web/letsencrypt/.well-known>            Options -Indexes            Require all granted   </Directory>   <Location /.well-known>         ProxyPass !         Require all granted   </Location> 

Any ideas how I could solve this? I would have expected it to be a problem people do come across from time to time, but I haven’t found anything on the internet.

Descent for the cotangent complex along faithfully flat SCRs

By Theorem 3.1 of Bhatt-Morrow-Scholze II (https://arxiv.org/pdf/1802.03261.pdf), we know that for $ R$ a commutative ring, $ \wedge^{i}L_{(-)/R}$ satisfies descent for faithfully flat maps $ A \rightarrow B$ of (ordinary) $ R$ -algebras. Can this descent statement be promoted to, say, faithfully flat maps of simplicial commutative $ R$ -algebras (where $ R$ is either discrete or a simplicial commutative ring)? I am primarily interested in the case where $ i=1$ , as the proof of this claim along with an induction argument using a filtration, can probably give the $ i>1$ case.

Picking a random point along the edge of an area

I’m writing a Diffusion-limited aggregation simulation, and need to pick a random point along the edge of an area defined by a dimension pair of [width, height]. The point shouldn’t be deep within the area; it should always be on the border of one of the sides. This is the intended behavior:

(let [rand-gen (Random.)       dims [21 11]]    (dotimes [_ 25]     ; I'm casting to int so the output it legible     ;  I actually need doubles     (println       (mapv int (random-edge-coord dims rand-gen)))))  [13 0] [0 8] [15 10] [8 10] [20 0] [0 6] [20 2] [0 5] [7 10] [0 7] [0 10] [20 1] [6 0] [20 0] [0 2] [20 10] [15 0] [14 0] [7 0] [0 7] [12 0] [20 7] [20 4] [20 8] [20 4] 

This is the mess I came up with:

; These two functions are just for the sake of a MCVE (defn- random-boolean [^Random rand-gen]   (.nextBoolean rand-gen))  (defn- random-double [min, max, ^Random rand-gen]   (let [r (.nextDouble rand-gen)         spread (- max min)         rand (* spread r)]     (+ rand min)))  (defn random-edge-coord [dimensions, ^Random rand-gen]   (let [[w h] dimensions         vertical? (random-boolean rand-gen)         start? (random-boolean rand-gen)          x (if vertical?             ; Pick either the left or right edge             (if start?               0               (dec w))              ; Else, pick a random point along the top/bottom egde             (random-double 0 w rand-gen))          y (if vertical?             (random-double 0 h rand-gen)              (if start?               0               (dec h)))]      [x y])) 

The redundancy is killing me though. I can’t think of how to clean it up. I feel like this should be fairly straightforward to generalize, but I’m stuck. I figured I could clean it up introducing some anonymous functions:

(defn random-edge-coord [dimensions rand-gen]   (let [[w h] dimensions         vertical? (g/random-boolean rand-gen)         start? (g/random-boolean rand-gen)          edge #(if start? 0 (dec %))         rand-edge #(g/random-double 0 % rand-gen)          x (if vertical?             (edge w)             (rand-edge w))          y (if vertical?             (rand-edge h)             (edge h))]      [x y])) 

But that’s not a huge gain.

Any input here would be appreciated.

Linked list implementation along with unit test [Round 3]

Here are the changes I’ve made thanks to suggestions made by @vnp, and @Henrik Hansen. Here is the link to the previous code review: Linked list implementation along with unit test [Round 2]

I’ve made some new additions that were not mentioned and added more unit tests :). I really feel like I’m improving!

Implementation

using System; using System.Collections; using System.Collections.Generic;  namespace DataStructuresAndAlgorithms.DataStructures {     public class LinkedList<T> : IEnumerable<T>     {         class Node         {             public T Data { get; set; }             public Node Next { get; set; }             public Node Previous { get; set; }              public Node(T data)             {                 Data = data;             }         }          private Node _head, _tail;         public T Head => _head == null ? throw new NullReferenceException() : _head.Data;         public T Tail => _tail == null ? throw new NullReferenceException() : _tail.Data;         public bool IsEmpty { get { return Count > 0 ? false : true; } }         public int Count { get; private set; } = 0;          public LinkedList() { }          public LinkedList(IEnumerable<T> items)         {             foreach (var item in items)             {                 AddTail(item);             }         }          public void AddHead(T item)         {             var node = new Node(item);              if (_head == null && _tail == null)             {                 _head = node;                 _tail = node;                 Count += 1;             }             else             {                 node.Next = _head;                 _head.Previous = node;                 Count += 1;             }             _head = node;         }          public void AddTail(T item)         {             var node = new Node(item);              if (_tail == null && _head == null)             {                 _head = node;                 _tail = node;                 Count += 1;             }             else             {                 node.Previous = _tail;                 _tail.Next = node;                 Count += 1;             }             _tail = node;         }          public T RemoveHead()         {             if (_head == null) return default;             else             {                 var temp = _head.Next;                 _head = _head.Next;                 if (_head != null) _head.Previous = null;                 Count -= 1;                 if (temp == null) return default;                 return temp.Data;             }         }          public T RemoveTail()         {             if (_tail == null) return default;             else             {                 var temp = _tail.Previous;                 _tail = _tail.Previous;                 if (_tail != null) _tail.Next = null;                 Count -= 1;                 if (temp == null) return default;                 return temp.Data;             }          }          public bool Find(T item)         {             if (_head == null || _tail == null) return false;             var node = _head;             while (node.Data.Equals(item) == false)             {                 if (node.Next == null)                     return false;                 node = node.Next;             }             return true;         }          public bool Remove(int index)         {             if (_head == null || _tail == null) return false;             var node = _head;             for (int i = 0; i < Count; i++)             {                 if (i == index) break;                 node = node.Next;             }             // Remove the node             if (node == null) return false;             bool isRemoved = NodeAwareRemove(node);             return isRemoved;         }          private bool NodeAwareRemove(Node node)         {             if (node.Next != null && node.Previous != null)             {                 // In between nodes                 node.Previous.Next = node.Next;                 node.Next.Previous = node.Previous;                 Count -= 1;                 return true;             }              if (node.Next != null && node.Previous == null)             {                 // Head node                 RemoveHead();                 Count -= 1;                 return true;             }              if (node.Previous != null && node.Next == null)             {                 // Tail node                 RemoveTail();                 Count -= 1;                 return true;             }              if (node.Next == null && node.Previous == null)             {                 // Only node                 _head = null;                 _tail = null;                 Count -= 1;                 return true;             }             return false;         }          public int RemoveAll(T item)         {             if (_head == null || _tail == null) return -1;             var node = _head;             int numberRemoved = 0;             while (node != null)             {                 if (node.Data.Equals(item))                 {                     if (NodeAwareRemove(node)) numberRemoved += 1;                 }                 node = node.Next;             }             return numberRemoved;         }          public T GetIndex(int index)         {             if (index < 0) throw new IndexOutOfRangeException();             if (index > Count) throw new IndexOutOfRangeException();             if (index == 0) return _head.Data;              var temp = _head;              for (int i = 0; i < Count; i++)             {                 if (i == index) break;                 temp = temp.Next;             }              return temp.Data;         }          public bool SetIndex(int index, T item)         {             if (index < 0) throw new IndexOutOfRangeException();             if (index > Count) throw new IndexOutOfRangeException();             if (index == 0) _head.Data = item;              var temp = _head;              for (int i = 0; i < Count; i++)             {                 if (i == index) break;                 temp = temp.Next;             }              temp.Data = item;             return true;         }          public object this[int i]         {             get { return GetIndex(i); }             set { SetIndex(i, (T)value); }         }          public IEnumerator<T> GetEnumerator()         {             var pointer = _head;             while (pointer != null)             {                 yield return pointer.Data;                 pointer = pointer.Next;             }         }          IEnumerator IEnumerable.GetEnumerator()         {             return GetEnumerator();         }     } }  

Unit Test

using System; using Xunit;  using DataStructuresAndAlgorithms.DataStructures;  namespace DataStructuresAndAlgorithms.DataStructures.Tests {     public class LinkedListTest     {         [Fact]         public void AddHead_Node_Should_Become_Head()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.AddHead(45);              // Assert             Assert.Equal(45, myLinkedList.Head);         }          [Fact]         public void AddTail_Node_Should_Become_Tail()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.AddTail(7777);              // Assert             Assert.Equal(7777, myLinkedList.Tail);         }          [Fact]         public void RemoveHead_Next_Node_Should_Be_Head()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.RemoveHead();              // Assert             Assert.Equal(2, myLinkedList.Head);         }          [Fact]         public void RemoveTail_Next_Node_Should_Be_Tail()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.RemoveTail();              // Assert             Assert.Equal(4, myLinkedList.Tail);         }          [Fact]         public void Find_5_Should_Return_True()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             var isFound = myLinkedList.Find(5);              // Assert             Assert.True(isFound);         }          [Fact]         public void IsEmpty_Should_Return_False_Count_Equal_5()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             var isEmpty = myLinkedList.IsEmpty;              // Assert             Assert.False(isEmpty);         }          [Fact]         public void IsEmpty_Should_Return_True_Count_Equal_0()         {             // Arrange             int[] myNums = { };              var myLinkedList = new LinkedList<int>(myNums);              // Act             var isEmpty = myLinkedList.IsEmpty;              // Assert             Assert.True(isEmpty);         }          [Fact]         public void GetIndex_4_Should_Equal_5()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             var index = myLinkedList.GetIndex(4);              // Assert             Assert.Equal(5, index);         }          [Fact]         public void SetIndex_2_10_Should_Set_Index_2_To_10()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.SetIndex(2, 10);              // Assert             Assert.Equal(10, myLinkedList[2]);         }          [Fact]         public void RemoveAll_Should_Delete_All_5s()         {             // Arrange             int[] myNums = { 5, 5, 5, 3, 2, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.RemoveAll(5);              // Assert             Assert.False(myLinkedList.Find(5));         }          [Fact]         public void Remove_1_Should_Return_True()         {             // Arrange             int[] myNums = { 5, 5, 5, 3, 2, 5 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             bool isRemoved = myLinkedList.Remove(1);              // Assert             Assert.True(isRemoved);         }          [Fact]         public void Remove_2_Should_Return_False()         {             // Arrange             int[] myNums = { 1 };              var myLinkedList = new LinkedList<int>(myNums);              // Act             bool isRemoved = myLinkedList.Remove(2);              // Assert             Assert.False(isRemoved);         }          [Fact]         public void AddHead_Should_Increment_Count()         {             // Arrange             int[] myNums = { 1 };              var myLinkedList = new LinkedList<int>(myNums);              var theCount = myLinkedList.Count;              // Act             myLinkedList.AddHead(7);             myLinkedList.AddHead(7);             myLinkedList.AddHead(7);             myLinkedList.AddHead(7);             myLinkedList.AddHead(7);              // Assert             Assert.Equal(theCount + 5, myLinkedList.Count);         }          [Fact]         public void Remove_2_Should_Decrement_Count()         {             // Arrange             int[] myNums = { 1 };              var myLinkedList = new LinkedList<int>(myNums);              var theCount = myLinkedList.Count;              // Act             myLinkedList.RemoveTail();              // Assert             Assert.Equal(theCount - 1, myLinkedList.Count);         }     } }  

Presentation

using System; using System.Collections;  using DataStructuresAndAlgorithms.DataStructures;  namespace DataStructuresAndAlgorithms.Presentation.Console {     class Program     {         static void Main(string[] args)         {             RunLinkedList();         }          static void RunLinkedList()         {             System.Console.WriteLine("Running the LinkedList class");             System.Console.WriteLine("----------------------------");             var myLinkedList = new LinkedList<int>();             myLinkedList.AddHead(1);             myLinkedList.AddHead(2);             myLinkedList.AddHead(3);             myLinkedList.AddHead(4);             myLinkedList.AddHead(5);             myLinkedList.RemoveHead();             myLinkedList.RemoveTail();             myLinkedList.SetIndex(2, 10);             myLinkedList[2] = 2;             System.Console.WriteLine("Count = " + myLinkedList.Count);             System.Console.WriteLine("Is Empty = " + myLinkedList.IsEmpty);             PrintList<int>(myLinkedList);         }          static void PrintList<T>(LinkedList<T> myList)         {             if (myList.Head == null || myList.Tail == null) return;              var listText = "LinkedList[";             for (int i = 0; i < myList.Count; i++)             {                 listText += myList[i];                 if (i < myList.Count - 1)                 {                     listText += "<";                     listText += "---";                     listText += ">";                 }             }             listText += "]";              System.Console.WriteLine(listText);             System.Console.WriteLine("Found Data = 66 -> " + myList.Find((T)(object)66));             System.Console.WriteLine("Found Data = 3 -> " + myList.Find((T)(object)3));         }     } }  

Does client have to send the CA chain along with the client certificate after ServerHello?

During the MTLS handshake, after ServerHello is done client sends the client certificate back to the server, I need to know if the client should only send the client certificate or is it required to send the client cert along with the entire CA chain ?

I have a situation where I am seeing a handshake failure post CertificateVerify. The client cert looks good and it is signed out of subCA which is signed out of a RootCA that the server also trusts (server only trusts root ca , not the subCA), in this situation we see the client only sending back the client cert without the chain, is that why I see the handshake failure ?? I am wondering if the client sent the entire CA chain back, the server would have know that the client is signed by SubCA which is then signed by a root CA that it trusts… I have googled and found lot of information around server sending cert with CA chain and acceptable CAs to client .. but not anything around what client should do..

any help is appreciated.

Linked list implementation along with unit test [Round 2]

Thank you Henrik Hansen for the amazing code review. Here is the new LinkedList class and accompanying unit test after suggestions made by Henrik Hansen.

Here’s the link to the previous code review: Linked list implementation along with unit test

Implementation

/*************************************************************************************************************  *  *  Special Thanks to Henrik Hansen for the awesome code review!  *  Url: https://codereview.stackexchange.com/questions/216453/linked-list-implementation-along-with-unit-test  *  *************************************************************************************************************/  using System; using System.Collections; using System.Collections.Generic;  namespace DataStructuresAndAlgorithms.DataStructures {     public class LinkedList<T> : IEnumerable<T>     {         class Node         {             public T Data { get; }             public Node Next { get; set; }             public Node Previous { get; set; }              public Node(T data)             {                 Data = data;             }         }          private Node _head, _tail;         public T Head => _head == null ? throw new ArgumentNullException("Head is null") : _head.Data;         public T Tail => _tail == null ? throw new ArgumentNullException("Tail is null") : _tail.Data;          public LinkedList() { }          public LinkedList(IEnumerable<T> items)         {             foreach (var item in items)             {                 AddTail(item);             }         }          public void AddHead(T item)         {             if (item == null)                 throw new ArgumentNullException("AddHead: An item you are trying to add is not initialized!");              if (_head == null && _tail == null)             {                 _head = new Node(item);                 _tail = _head;             }             else             {                 _head.Previous = new Node(item);                 var temp = _head;                 _head = _head.Previous;                 _head.Next = temp;             }         }          public void AddTail(T item)         {             if (item == null)                 throw new ArgumentNullException("AddTail: An item you are trying to add is not initialized!");              if (_tail == null && _head == null)             {                 _tail = new Node(item);                 _head = _tail;             }             else             {                 _tail.Next = new Node(item);                 var temp = _tail;                 _tail = _tail.Next;                 _tail.Previous = temp;             }         }          public void RemoveHead()         {             if (_head == null) return;             else             {                 _head = _head.Next;                 if (_head == null) return;                 _head.Previous = null;             }         }          public void RemoveTail()         {             if (_tail == null) return;             else             {                 _tail = _tail.Previous;                 if (_tail == null) return;                 _tail.Next = null;             }          }          public bool Remove(T item)         {             var pointer = _head;             while (pointer.Data.Equals(item) == false)             {                 if (pointer.Next == null)                     return false;                 pointer = pointer.Next;             }              if (pointer.Previous == null)             {                 // It is the Head                 pointer.Next.Previous = null;                 return true;             }             if (pointer.Next == null)             {                 // It is the Tail                 pointer.Previous.Next = null;                 return true;             }             pointer.Previous.Next = null;             pointer.Next.Previous = null;             return true;         }          public IEnumerator<T> GetEnumerator()         {             var pointer = _head;             while (pointer != null)             {                 yield return pointer.Data;                 pointer = pointer.Next;             }         }          IEnumerator IEnumerable.GetEnumerator()         {             return GetEnumerator();         }     } } 

Unit Test

using System; using Xunit;  using DataStructuresAndAlgorithms.DataStructures;  namespace DataStructuresAndAlgorithms.DataStructures.Tests {     public class LinkedListTest     {         [Fact]         public void AddHead_Node_Should_Become_Head()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.AddHead(45);              // Assert             Assert.Equal(45, myLinkedList.Head);         }          [Fact]         public void AddTail_Node_Should_Become_Tail()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.AddTail(7777);              // Assert             Assert.Equal(7777, myLinkedList.Tail);         }          [Fact]         public void RemoveHead_Next_Node_Should_Be_Head()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.RemoveHead();              // Assert             Assert.Equal(2, myLinkedList.Head);         }          [Fact]         public void RemoveTail_Next_Node_Should_Be_Tail()         {             // Arrange             int[] myNums = { 1, 2, 3, 4, 5 };             var myLinkedList = new LinkedList<int>(myNums);              // Act             myLinkedList.RemoveTail();              // Assert             Assert.Equal(4, myLinkedList.Tail);         }     } } 

Presentation

using System; using System.Collections;  using DataStructuresAndAlgorithms.DataStructures;  namespace DataStructuresAndAlgorithms.Presentation.Console {     class Program     {         static void Main(string[] args)         {             RunLinkedList();         }          static void RunLinkedList()         {             System.Console.WriteLine("Running the LinkedList class");             System.Console.WriteLine("----------------------------");             var myLinkedList = new LinkedList<int>();             myLinkedList.AddHead(54);             myLinkedList.AddHead(44);             myLinkedList.AddHead(96);             myLinkedList.AddTail(300);             myLinkedList.AddTail(900);             myLinkedList.AddTail(77);             myLinkedList.Remove(900);              System.Console.WriteLine("HEAD = " + myLinkedList.Head);             System.Console.WriteLine("TAIL = " + myLinkedList.Tail);              foreach (var item in myLinkedList)             {                 System.Console.WriteLine(item);             }         }     } } ``` 

Linked list implementation along with unit test

I want to see how other people think of my code, so here it goes. This is my first time writing a unit test. I’m wondering if there needs to be more tests for the LinkedList class and also if I’m writing them correctly.

I’ve made the Node class public so I can use it for a binary tree implementation later.

namespace DataStructuresAndAlgorithms.DataStructures {     public class Node<T>     {         public T Data { get; set; }         public Node<T> Next { get; set; }         public Node<T> Previous { get; set; }          public Node() { }          public Node(T t)         {             Data = t;         }     } } 

Implementation

using System; using System.Collections.Generic;  namespace DataStructuresAndAlgorithms.DataStructures {     public class LinkedList<T>     {         public Node<T> Head { get; private set; }         public Node<T> Tail { get; private set; }          public LinkedList(Node<T> node)         {             Head = node;             Tail = node;         }          public void AddToFirst(Node<T> toAdd)         {             toAdd.Next = Head;             Head = toAdd;         }          public void AddToLast(Node<T> toAdd)         {             Tail.Next = toAdd;             Tail = toAdd;         }          public void RemoveFirst()         {             Head = Head.Next;         }          public void RemoveLast()         {             var pointer = Head;             while (pointer.Next != Tail)             {                 pointer = pointer.Next;             }             // pointer is now before Tail             Tail = pointer;             Tail.Next = null;         }          public IEnumerator<Node<T>> GetEnumerator()         {             var pointer = Head;             while (pointer != null)             {                 yield return pointer;                 pointer = pointer.Next;             }         }     } }  

Unit Test

using System; using Xunit;  using DataStructuresAndAlgorithms.DataStructures;  namespace DataStructuresAndAlgorithms.DataStructures.Tests {     public class LinkedListTest     {         [Fact]         public void AddToFirst_Node_Should_Become_Head()         {             // Arrange             var myLinkedList = new LinkedList<int>(new Node<int>(45));              // Act             var nodeToAdd = new Node<int>(67);             myLinkedList.AddToFirst(nodeToAdd);              // Assert             var theNode = GetNodeFromList<int>(myLinkedList, nodeToAdd);             Assert.Equal(nodeToAdd, theNode);             Assert.Equal(45, theNode.Next.Data);         }          [Fact]         public void AddToLast_Node_Should_Become_Tail()         {             // Arrange             var myLinkedList = new LinkedList<int>(new Node<int>(35));              // Act             var nodeToAdd = new Node<int>(14);             myLinkedList.AddToLast(nodeToAdd);              // Assert             var theNode = GetNodeFromList<int>(myLinkedList, nodeToAdd);             Assert.Equal(nodeToAdd, theNode);         }          [Fact]         public void RemoveFirst_Next_Node_Should_Be_Head()         {             // Arrange             var myLinkedList = new LinkedList<int>(new Node<int>(777));              var node1 = new Node<int>(1);             myLinkedList.AddToLast(node1);              var node2 = new Node<int>(2);             myLinkedList.AddToLast(node2);              var node3 = new Node<int>(3);             myLinkedList.AddToLast(node3);              // Act             myLinkedList.RemoveFirst();              // Assert             var theNode = GetNodeFromList<int>(myLinkedList, node1);             Assert.Equal(node1, myLinkedList.Head);         }          [Fact]         public void RemoveLast_Next_Node_Should_Be_Tail()         {             // Arrange             var myLinkedList = new LinkedList<int>(new Node<int>(777));              var node1 = new Node<int>(1);             myLinkedList.AddToLast(node1);              var node2 = new Node<int>(2);             myLinkedList.AddToLast(node2);              var node3 = new Node<int>(3);             myLinkedList.AddToLast(node3);              // Act             myLinkedList.RemoveLast();              // Assert             var theNode = GetNodeFromList<int>(myLinkedList, node2);             Assert.Equal(node2, myLinkedList.Tail);         }          public static Node<T> GetNodeFromList<T>(LinkedList<T> someLinkedList, Node<T> someNode) where T : struct         {             using (var itr = someLinkedList.GetEnumerator())             {                 while (itr.Current != someNode)                 {                     itr.MoveNext();                 }                 return itr.Current;             }         }     } }  

Presentation

using System; using System.Collections;  using DataStructuresAndAlgorithms.DataStructures;  namespace DataStructuresAndAlgorithms.Presentation.Console {     class Program     {         static void Main(string[] args)         {             RunNode();             System.Console.WriteLine();             RunLinkedList();         }          static void RunNode()         {             System.Console.WriteLine("Running the Node class");             System.Console.WriteLine("----------------------");             var myNode = new Node<int>(32);             System.Console.WriteLine(myNode.Data);         }          static void RunLinkedList()         {             System.Console.WriteLine("Running the LinkedList class");             System.Console.WriteLine("----------------------------");             var myLinkedList = new LinkedList<int>(new Node<int>(99));             myLinkedList.AddToFirst(new Node<int>(56));             myLinkedList.AddToFirst(new Node<int>(23));             myLinkedList.AddToFirst(new Node<int>(33));             myLinkedList.AddToLast(new Node<int>(8888));             myLinkedList.RemoveLast();             myLinkedList.RemoveFirst();             System.Console.WriteLine("HEAD = " + myLinkedList.Head.Data);             System.Console.WriteLine("TAIL = " + myLinkedList.Tail.Data);              using (var linkedListEnumerator = myLinkedList.GetEnumerator())             {                 while (linkedListEnumerator.MoveNext())                 {                     System.Console.WriteLine(linkedListEnumerator.Current.Data);                 }             }         }     } }  ``` 

How to launch JADE along with Reasoning Engine?

I am new to JAVA

I am trying to run Multi Agent Framework (JADE) developed in Java. I downloaded its binaries from here. http://jade.tilab.com/dl.php?file=JADE-bin-4.5.0.zip

As per the instruction given in tutorial; I unziped it in C:/Jade. I have following directory structure there: Fig: 1 enter image description here As per the tutorial I installed Emerald from http://lpis.csd.auth.gr/systems/emerald/resource.html, a resoning engine on C:/Jade. During installation I used Dr-device as an engine. So it created another folder of Dr-Device in Emerald I have following directory structure there: Fig: 2 enter image description here

When I execute following bat file on C:\Jade\Emerald\emerald.bat. It gives me an error that no Jade.boot found. rem @echo off echo EMERALD 1.0 if EXIST DR-DeviceAgent set dr-device-agent=DR_Reasoner:ReasoningAgent if EXIST R-DeviceAgent set r-device-agent=R_Reasoner:ReasoningAgent_R if EXIST SPINdleAgent set spindle-agent=SPINdle_Reasoner:SPINdleAgent if EXIST ProvaAgent set prova-agent=Prova_Reasoner:provaAgent java jade.Boot -gui %r-device-agent% %dr-device-agent% %prova-agent% %spindle-agent%

I changed last command to: java -cp ..\lib\jade.jar jade.Boot -gui %dr-device-agent% because jar file was present somewhere else in directory tree.

It successfully launched Jade framework. But during launch it gave a warning that it was unable to find “ReasoningAgent.class” whereas it is present there as show in following figure Fig: 3 enter image description here

Error in console can be seen in image below(Last 4th and 5th line) If it was successful in creating an agent reasoner. There must be 4 agents in gui Fig: 4 enter image description here

matlab: addition of symbolic matrices along an unused dimension

How can symbolic matrices collected in a cell array be summed along an unused dimension? Assume, for reasons beyond the scope of this post, that the matrices must be the elements of a cell array, rather than planes of a higher-dimensional matrix. What follows is a brief demonstration of the problem.

Suppose we have a cell array of 2D sym vectors prepared as follows:

a = vpa(ones(2,2)); c = {a; 2*a; 3*a}; 

Despite the fact that it is possible to make multidimensional symbolic matrices with newer versions of matlab (e.g., sym('c', [2 2 2])), addition of 2D sym matrices along a third dimension fails

sum(cat(3, c{:}), 3)     Error using symengine     Arguments must be 2-dimensional. 

With numeric inputs, the operation is successful:

a = ones(2,2); c = {a; 2*a; 3*a}; sum(cat(3,c{:}), 3)     6    6     6    6