It's possible to create a new ASP.NET Core project entirely from the command line using the dotnet command.
dotnet new web
dotnet restore
dotnet run
dotnet new web scaffolds a new "empty" web project. The web parameter tells the dotnet tool to use the ASP.NET Core Empty template. Use...
Using Razor @functions keyword gives the capability of introducing classes and methods for inline use within a Razor file:
@functions
{
string GetCssClass(Status status)
{
switch (status)
{
case Status.Success:
return "alert-success&qu...
Once the Symfony Installer is available, create your first Symfony application with the new command:
# Linux, Mac OS X
$ symfony new my_project_name
# Windows
c:\> cd projects/
c:\projects\> php symfony new my_project_name
This command can be run from anywhere, not necessarily from t...
using System.Net;
using System.IO;
...
string requestUrl = "https://www.example.com/submit.html";
HttpWebRequest request = HttpWebRequest.CreateHttp(requestUrl);
request.Method = "POST";
// Optionally, set properties of the HttpWebRequest, such as:
request.AutomaticD...
using System.Net;
using System.IO;
...
string requestUrl = "https://www.example.com/page.html";
HttpWebRequest request = HttpWebRequest.CreateHttp(requestUrl);
// Optionally, set properties of the HttpWebRequest, such as:
request.AutomaticDecompression = DecompressionMethods.GZ...
Two Random class created at the same time will have the same seed value.
Using System.Guid.NewGuid().GetHashCode() can get a different seed even in the same time.
Random rnd1 = new Random();
Random rnd2 = new Random();
Console.WriteLine("First 5 random number in rnd1");
for (int i = 0...
We can use jasmine.createSpy() to create a standalone spy. This is often useful if we need to pass a function as a callback to another function and want to test how it is used.
// source code
function each(arr, fn) {
arr.forEach(fn);
}
// test code
describe('each', function() {
let m...
The NSDate class provides methods for creating NSDate objects corresponding to a given date and time. An NSDate can be initialized using the designated initializer, which:
Returns an NSDate object initialized relative to 00:00:00 UTC on 1 January 2001 by a given number of seconds.
NSDate *date...
To support a given application, you often create a new role and database to match.
The shell commands to run would be these:
$ createuser -P blogger
Enter password for the new role: ********
Enter it again: ********
$ createdb -O blogger blogger
This assumes that pg_hba.conf has been prope...
An array of strings can mean a couple of things:
An array whose elements are char *s
An array whose elements are arrays of chars
We can create an array of character pointers like so:
char * string_array[] = {
"foo",
"bar",
"baz"
};
Remember: w...
Using the default constructor
T variable = Activator.CreateInstance(typeof(T));
Using parameterized constructor
T variable = Activator.CreateInstance(typeof(T), arg1, arg2);
A common usage scenario that this feature really helps with is when you are looking for an object in a collection and need to create a new one if it does not already exist.
IEnumerable<MyClass> myList = GetMyList();
var item = myList.SingleOrDefault(x => x.Id == 2) ?? new MyClass { Id = 2...
Creating a Custom Element with bindable properties is a snap. If you want to create an element that accepts one or more values which the plugin can use, the @bindable decorator and syntax is what you are looking for.
Below, we are creating a custom element that accepts an array of fruits and displa...
A basic custom element is created in Aurelia based on naming conventions, by simply adding the suffix CustomElement to the name of a class. This suffix will automatically be stripped out by Aurelia. The remaining part of the class name will be lowercased and separated using a hyphen and can then be ...