Shortcut for Directory – PowerShell

It’s been for a while since I started using PowerShell for some operations. It might seem complicated at the beginning but if you be patient and keep learning, it makes so many tasks easy for you, especially for .NET developers.

To create aliases for the commands:

New-Alias show Get-ChildItem 

And when you use it

 show 

It will list the files & folders in the current directory, just like DIR or LS.

When you close the current PowerShell session, this alias will be removed. In order to make it permanent, you will need to create a file with the name Microsoft.PowerShell_profile.ps1 under PSConfiguration folder under  Windows PowerShell profile folder. To learn your Windows PowerShell profile folder, use

Get-Variable profile | Format-List

So the location of the new file would be like  >

Windows PowerShell profile folder/PSConfiguration/Microsoft.PowerShell_profile.ps1

If you create/edit this file and add the new aliases to it, they will be available for all sessions.

There is one issue about creating an alias for navigating folders – it is not possible. Aliases are just for command, in order to navigate a directory, you will need to create a function in the Microsoft.PowerShell_profile.ps1 file.

function myproject { set-location "C:\Users\Dude\Desktop\MyImportanProject" }
function desktop { set-location "C:\Users\Dude\Desktop\" }

After you save this functions in the file and reopen PowerShell, you can use the commands by just typing 

myproject
desktop

Information provided here is a summary from official support page here >> https://technet.microsoft.com/en-us/library/ee176913.aspx

Posted in powershell | Tagged , , , , , | Leave a comment

.NET Core Command Line CLI Basics

Yes, developing .NET apps without opening Visual Studio was something I wish for a long time. It was possible but wasn’t that simple. With .NET Core CLI, managing the project is simpler than ever. Let’s see how we can create a new project, build and run and learn some more commands.

1. Creating a Project/Solution & Adding Project to a Solution

After going to the folder you want to create the project. You can just type

 "dotnet new"

This will not work but you will see the options you can use.

For an MVC project, you can use

 "dotnet new mvc"

For a console app, use

 "dotnet new console"

If you want to create the project in a folder with a solution name you desire, use

 "dotnet new mvc -n MyNewMvcProject"

Once you do any of above, the files for the project will be created and you can jump start working on your projects. Details for the “dotnet new” command can be found here >>>

If you want to add projects under the solution, use “dotnet sln []” command. Click to see more details.

2. Running / Building the Projects

For running the project quickly, use

dotnet run

If you get an error of missing files, you have to restore the packages. Use

 dotnet restore 

This restores the dependencies and tools of a project that are specified in the project file. Note that “dotnet run” command, takes care of compiling and building the project as well. It runs “dotnew build” before it runs.

3. Adding Packages to the Projects & Adding Projects as Reference

You can use “dotnet add package PackageName” to add a package from NuGET. For example, to add Newtonsoft.Json, use

dotnet add package Newtonsoft.Json

You can specify the URL of the package as well:

dotnet add package Microsoft.AspNetCore.StaticFiles -s https://dotnet.myget.org/F/dotnet-core/api/v3/index.json

The commands above must be the most used ones. For all, please visit the official article on microsoft >> .NET Core command-line interface (CLI) tools

Posted in .NET Core | Tagged , , , | Leave a comment

Why Brackets in SQL queries with SQL Server

It’s been long time since I worked with SQL Server last time. I have been working with Oracle and there are differences for sure. This one is simple.

  1. The brackets are required if you use keywords or special chars in the column names or identifiers. You could name a column [First Name] (with a space)–but then you’d need to use brackets every time you referred to that column.
  2. They’re handy if your columns have the same names as SQL keywords, or have spaces in them.Example:create table test ( id int, user varchar(20) )
    Oh no! Incorrect syntax near the keyword ‘user’. But this:

    create table test ( id int, [user] varchar(20) )
    Works fine.

  3. Regardless of following a naming convention that avoids using reserved words, Microsoft does add new reserved words. Using brackets allows your code to be upgraded to a new SQL Server version, without first needing to edit Microsoft’s newly reserved words out of your client code. That editing can be a significant concern. It may cause your project to be prematurely retired….Brackets can also be useful when you want to Replace All in a script. If your batch contains a variable named @String and a column named [String], you can rename the column to [NewString], without renaming @String to @NewString.

Source: http://stackoverflow.com/questions/52898/what-is-the-use-of-the-square-brackets-in-sql-statements

Posted in Databases, MSSQL, Uncategorized | Tagged | Leave a comment

Top Screen Resolutions and Browsers

The top screen resolutions from Oct 2015 to Oct 2016

statcounter-resolution-ww-monthly-201510-201610-bar

Last month with mobile devices included

StatCounter-resolution-ww-monthly-201608-201610-bar.png

Top 5 browsers

statcounter-browser-ww-monthly-201510-201610-bar

Posted in Uncategorized | Leave a comment

Inheritance Simply

Basics are important. Involving in big projects may make us underestimate and forget about the basics. While I was rechecking the important feature of OOP: inheritance, I wanted to share very simple example briefly.

My little piece of code here calculates the surface and volume of a rectangular prism and calculates its cost based on its volume.

Firtly, I created a base class which is called RectangularPrism, added three number we need for calculation: length,width,height, created the public constructor and then created the methods for calculating volume, surface and displaying the all features of the rectangular prism.


class RectangularPrism
{
protected double length;
protected double width;
protected double height;

public RectangularPrism(double l,double w,double h)
{
length = l;
width = w;
height = h;
}
public double GetSurface()
{
return (2 * ((length * width) +(length * height) +(width * height)));
}

public double GetVolume()
{
return length * width * height;
}
public void Display()
{
Console.WriteLine("Length: {0}",length);
Console.WriteLine("Width: {0}",width);
Console.WriteLine("Height: {0}",height);
Console.WriteLine("Surface: {0}", GetSurface());
Console.WriteLine("Volume: {0}", GetVolume());
}
}

Next, I created another class called Box inherited from RectangularPrism. Additional to the features of base class, Box class has a method to calculate the cost according to its volume. (Volume x 2 is my formula for calculating the cost). It has also a Display() method which runs base.Display and runs an additional Console.Write method.


class Box : RectangularPrism
{
public Box(double l, double w, double h) : base(l,w,h)
{ }

public double GetCost()
{
double cost;
cost = GetVolume() * 2;
return cost;

}

public new void Display()
{
base.Display();
Console.WriteLine("Cost: {0}", GetCost());
}
}

Lastly, we can use our classes and create and object in our main method of the class.


class Program
{
static void Main(string[] args)
{
Box myBox = new Box(8,4,4);
myBox.Display();
Console.ReadLine();

}
}

With those numbers, it will give us following result:

inheritance_csharp

Inheritance, together with encapsulation and polymorphism, is one of the three primary characteristics (or pillars) of object-oriented programming. Inheritance enables you to create new classes that reuse, extend, and modify the behavior that is defined in other classes.

For more information from msdn >>

Posted in C# | Tagged , | Leave a comment

Redmine Reports & Business Intelligence

We have been using Redmine for 3 months actively and the number of issues is now over 11000 with 90 projects and 200 users. When it comes to getting various reports for different objectives , Redmine’s capability is very limited. Especially if you are working with customers from very different fields, the reports you need for each project become unique. You may even have to create a report for human resources department as they are also interested in what is going on with the projects and the time spent on them, or even they may be curios about the projects which consumes most of the labor time.

You have various options like RedmineIssueSummary and some plugins exist for reporting. If you have high number of issues and projects, you will definitely need a custom report at the end. Continue reading

Posted in Business Intelligence, Jaspersoft Studio, Redmine, SpagoBI | Tagged , , , , , , , , , , , | 1 Comment

Oracle Function & .NET sysdate problem

After I shared one solution about oracle, iis and sysdate problem, I got another similar error. This time, the function was getting the paramater sysdate with time added. I noticed this because the function was calculating default insterest of a price, and each hour it was increasing the total amoun.

After many tries, I removed NS_LANG key from reg entry of Oracle. See below.

NS_LANG_Oracle_NET

If it doesnt work, try to add your language and setting, Turkish in my case.

e-belediye_makinesi

Posted in .NET, IIS, ORACLE | Tagged , , | Leave a comment