Tutorial by Examples

After the install of an IoC (Inversion of Control) container, some tweaks are needed to make it work. In this case, I'll use Ninject. In the NinjectWebCommon file, that is located in the App_Start folder, substitute the CreateKernel method with: private static IKernel CreateKernel() { ...
In the concrete class that need the service, use the interface to access the service instead of its implementation like: public class BenefitAppService { private readonly IBenefitService _service; public BenefitAppService(IBenefitService service) { _service = service; ...
By default, the full indexed document is returned as part of all searches. This is referred to as the source (_source field in the search hits). If we don’t want the entire source document returned, we have the ability to request only a few fields from within source to be returned, or we can set _so...
By default, a Docker container won't be able to run a GUI application. Before that, the X11 socket must be forwarded first to the container, so it can be used directly. The DISPLAY environment variable must be forwarded as well: docker run -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=unix$DISPLAY &...
In command mode(Esc) enter :gg=G to use Vim's built-in indention engine. Command PartDescriptionggstart of file=indent (when equalprg is empty)Gend of file You can set equalprg in your .vimrc to use a more sophisticated auto-formatting tool. For example, to use clang-format for C/C++ put the foll...
Since Node is single-threaded, there is a need of workaround if it comes to a long-running calculations. Note: this is "ready to run" example. Just, don't forget to get jQuery and install the required modules. Main logic of this example: Client sends request to the server. Server sta...
Arrays in MATLAB are held as continuous blocks in memory, allocated and released automatically by MATLAB. MATLAB hides memory management operations such as resizing of an array behind easy to use syntax: a = 1:4 a = 1 2 3 4 a(5) = 10 % or alternatively a = [a, 10] a = ...
<asp:Literal runat="server" text="<%$ AppSettings:MyAppSettingName %>"/>
<div> The time is now <%= DateTime.Now.ToString() %> </div>
<div> <form id="form1" runat="server"> <% for (int i = 1; i <= 10; j++) { Response.Write(i) + " "; } %> </form> <div>
Docs file (Input File) Mary had a little lamb its fleece was white as snow and everywhere that Mary went the lamb was sure to go. Hive Query CREATE TABLE FILES (line STRING); LOAD DATA INPATH 'docs' OVERWRITE INTO TABLE FILES; CREATE TABLE word_counts AS SELECT word, count(1) AS count F...
The example is taken from threejs website. You may want to download three.js and change the script source below. There are many more advanced examples under this link. HTML: <html> <head> <meta charset=utf-8> <title>My first Three.js app</title> <...
When reading a potentially large file, a while loop has a significant memory advantage over foreach. The following will read the file record by record (by default, "record" means "a line", as specified by $/), assigning each one to $_ as it is read: while(<$fh>) { pri...
If you have a list in memory already, the straightforward and usually sufficient way to process it is a simple foreach loop: foreach my $item (@items) { ... } This is fine e.g. for the common case of doing some processing on $item and then writing it out to a file without keeping the data ...
Amazon Linux is a RHEL variant, so the Red Hat instructions should work for the most part. There is, however, at least one discrepancy. There was an instance where the python27-devel package, as opposed to python-devel, was explicitly necessary. Here, we will install from source. sudo yum -y upd...
There are many fine ways to get this done, which others have already suggested. Following along the "get Excel data via SQL track", here are some pointers. Excel has the "Data Connection Wizard" which allows you to import or link from another data source or even within the very ...
php artisan make:request StoreUserRequest php artisan make:request UpdateUserRequest Note: You can also consider using names like StoreUser or UpdateUser (without Request appendix) since your FormRequests are placed in folder app/Http/Requests/.
[Test] public void Calculator_Add_ReturnsSumOfTwoNumbers() { Calculator calculatorUnderTest = new Calculator(); double result = calculatorUnderTest.Add(2, 3); Assert.AreEqual(5, result); }
Given this simple class, we can test that the ShaveHead method is working correctly by asserting state of the HairLength variable is set to zero after the ShaveHead method is called. public class Person { public string Name; public int HairLength; public Person(string name, in...
Sometimes it is necessary to assert when an exception is thrown. Different unit testing frameworks have different conventions for asserting that an exception was thrown, (like NUnit's Assert.Throws method). This example does not use any framework specific methods, just built in exception handling. ...

Page 869 of 1336