Tuesday, 21 May 2013

PS4 vs Xbox One specification

So Microsoft finally revealed latest Xbox spec.


From first look Ps4 got better Ram which is quite important for high performance in video games. Apparently Xbox one GPU is only 1.2 Teraflops comparing to 1.84 from Ps4, however I am not certainly sure about this. 

Having really powerful machine does not always guarantee a good  reliable software/video game. Developers need some time to learn how to speak to new hardware and it might take few years until they will be able to use the full power of both platforms. I still can remember 1994 when games for Ps1 looks totally different than the ones from 1998, still the same hardware but developers mastered it. 
I am not a huge fan of Xbox as Microsoft Xbox division think it's fair to rip people off, however I have to say that even with worse specs Xbox might have some better games at the beginning of the new console generation race, correct me if I am wrong.

Let's hope so I am wrong as I much prefer Ps over xbox (I have both) for many reasons.

So I personally think that both consoles got the same chance in the new race for victory, however developers will have huge impact on consoles success.  

BTW Check Francis video about new xbox : http://www.youtube.com/watch?v=SyD1VlQdj2s

Monday, 13 May 2013

Exporting data to Excel and CSV in ASP.NET MVC application



We want to be able to export some information to Excel file or CSV file. We are going to create a simple class that will hold basic Client information (First name, last name, Date of birth and Email) and we are going to populate it with some dummy data to display it on a View (table) and then export it to Excel/CSV.
Within your new ASP.Net MVC (lets name it ExportToExcel_PDF_CSV) application in Model folder create a new class and call it ClientsList.cs.


You can download project from here : ExportToExcelCSVASPMVC
MODEL
  public class ClientsList
    {
        public ClientsList(string firstname, string lastname, DateTime dob, string email)
        {
            this.FirstName = firstname;
            this.LastName = lastname;
            this.Dob = dob;
            this.Email = email;
        }

        public string FirstName { set; get; }
        public string LastName { set; get; }
        public string Email { set; get; }
        public DateTime Dob { set; get; }

    }

Now in Home controller we are going to populate this class with some data. Make sure you instantiate this List within class so it will be available in every method in this controller.

CONTROLLER
public class HomeController : Controller
    {

List<ClientsList> ClientsList = new List<ClientsList>
            {
                 new ClientsList ( "Adam",  "Bielecki",  DateTime.Parse("22/05/1986"),       "adamb@example.com" ), 
                 new ClientsList (  "George", "Smith",  DateTime.Parse("10/10/1990"),  "george@example.com" )
            };

public ActionResult Index()
        {
            return View(ClientsList);
        }

}
VIEW
We are going to display data that came from controller and model we are using is List<ClientsList>.
@{
    ViewBag.Title = "Export";
}
@model List<ExportToExcel_PDF_CSV.Models.ClientsList>
<h2>
    Export to PDF, Excel CSV Example</h2>

    <table>
        <thead>
            <tr>
                <th>
                    First Name
                </th>
                <th>
                    Last Name
                </th>
                <th>
                    Date Of Birth Name
                </th>
                <th>
                    Email
                </th>
            </tr>
        </thead>
        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @item.FirstName
                </td>
                <td>@item.LastName
                </td>
                <td>@item.Dob
                </td>
                <td>
                    @item.Email
                </td>
            </tr>
        }
    </table>
    <div class="ExportSection">
        @Html.ActionLink("Export to Csv", "ExportClientsListToCSV")
        @Html.ActionLink("Export to Excel", "ExportClientsListToExcel")
       
    </div>


Add some styling to your Site.css style sheet.

/* Custom added

----------------------------------------------------------*/

.ExportSection
{
    margin:10px 0;
    float:left;
   
}
.ExportSection a
{
    text-decoration:none;
    padding:0 5px 0 0;
   
}





Now in controller we want to add 2 methods:
ExportClientsListToExcel
ExportClientsListToCSV

   public void ExportClientsListToCSV()
        {
         
            StringWriter sw = new StringWriter();

            sw.WriteLine("\"First Name\",\"Last Name\",\"Email\"");

            Response.ClearContent();
        Response.AddHeader("content-disposition", "attachment;filename=Exported_Users.csv");
            Response.ContentType = "text/csv";

            foreach (var line in ClientsList)
            {
                sw.WriteLine(string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\"",
                                           line.FirstName,
                                           line.LastName,
                                           line.Dob,
                                           line.Email));
            }

            Response.Write(sw.ToString());

            Response.End();

        }


public void ExportClientsListToExcel()
        {
            var grid = new System.Web.UI.WebControls.GridView();

            grid.DataSource = /*from d in dbContext.diners
                              where d.user_diners.All(m => m.user_id == userID) && d.active == true */
                              from d in ClientsList
                              select new
                              {
                                  FirstName = d.FirstName,
                                  LastName = d.LastName,
                                  DOB = d.Dob,
                                  Email = d.Email

                              };

            grid.DataBind();

            Response.ClearContent();
       Response.AddHeader("content-disposition", "attachment; filename=Exported_Diners.xls");
            Response.ContentType = "application/excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            grid.RenderControl(htw);

            Response.Write(sw.ToString());

            Response.End();

        }

In both cases we are using HttpResponseBase (Response) and stream writer.
In excel export we are using grid, so we can bind data to it.

You can download project from here : ExportToExcelCSVASPMVC
 

Friday, 10 May 2013

Metal Gear Rising: Revengeance OST - It Has To Be This Way -Extended Guitar Cover Adam Bielecki

So as some of you might already know I am a huge fan of Metal Gear Solid series:
My tribute to MGS series:


and when I saw first tech demo on E3 for Metal Gear Solid:Rising (that was the original name for the game back then) I was shocked with the ability to cut everything and every cut was calculated in a real time. Finally I got myself Metal Gear Rising:Revengeance and I have to honestly say it did not look as good as demo and story did not pull me in like in the all MGS series. After playing 30-40 minutes smile on my face suddenly appeared and I realize that this might be a new amazing genre and new path for Konami(Kojima still is going to make Metal Gear Solid series). I finished game 2 times already on Normal and Hard level and I have to honestly say that the game was challenging, due to lack of skills, but once I finished the game and I knew almost every combo, playing second time was even better and Raiden was undefeated even on hard level. Unfortunately developers did not really care about stealth, but there are few places you can sneak, however it's no near as fun as Solid Snake or Big Boss. To be honest why would you even want to sneak when you know that you can slice Gecko in 5 seconds and drink a tea while destroying Metal Gear!

I decided to pay my tribute to this game by playing my favorite song "It has to be this way"



You can get tabs for guitar pro here : http://tabs.ultimate-guitar.com/m/misc_computer_games/the_metal_gear_-_rising_it_has_to_be_this_way_guitar_pro.htm