archive-ro.com » RO » A » ALEXPETA.RO

Total: 36

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Simple Thousands HtmlHelper for Big Numbers
    extension method for Int that will make numbers like 3453 display like 3 4K To the code using System using System Collections Generic using System Linq using System Web namespace AlexPeta 2 Helpers public static class ThousandHelper public static string ThousandK this int helper double divisor 0D string letter string Empty if helper Math Pow 10D 6D divisor 6D letter M else if helper Math Pow 10D 3D helper 0D

    Original URL path: http://www.alexpeta.ro/blog/post/simple-thousands-htmlhelper-for-big-numbers (2016-05-01)
    Open archived version from archive


  • Y U No test speed code with BenchmarkNET
    that the algorithm complexity is variable I will make a couple of changes to my old code First I will start by using a SecretSanta class rather then writing the whole piece of code in a Console Application Main method using System using System Collections Generic using System Linq using System Text using BenchmarkNet namespace SecretSantaWithBenchmark public class SecretSanta private List string peopleToMatch get set private List string copyOfPeople get set private List int excludedPosibilities get set public Dictionary string string Results get set public SecretSanta List string users peopleToMatch users copyOfPeople users BenchmarkedThis BenchmarkNet BenchmarkType Sequential 25 MAR 2012 1 00 00 00 0014501 0 Initial test public void Start do Results new Dictionary string string excludedPosibilities new List int foreach string person in peopleToMatch var personPosibilites GetPosibilities person var rand new Random Next 0 personPosibilites Count Results Add person copyOfPeople personPosibilites rand excludedPosibilities Add personPosibilites rand while TestResults private List int GetPosibilities string current check List int return posibilities new List int for int i 0 i lt copyOfPeople Count i if copyOfPeople i current check excludedPosibilities Contains i return posibilities Add i return return posibilities private bool TestResults foreach string person in peopleToMatch if Results person person return false return true public override string ToString StringBuilder sb new StringBuilder foreach var person in Results Keys sb Append string Format 0 will get a present for 1 person ToUpper Results person ToUpper Append Environment NewLine return sb ToString The logic is mostly the same no huge difference in the logic The code testing will be done in our Main method using System using System Collections Generic using System Linq using System Text using BenchmarkNet namespace SecretSantaWithBenchmark class Program static void Main string args List string data new List string claudiu email com raluca email com alex email com

    Original URL path: http://www.alexpeta.ro/blog/post/y-u-no-test-speed-code-with-benchmarknet (2016-05-01)
    Open archived version from archive

  • Archive
    Tom Pat Leeson Science Photo Library Entity Framework and DBO Schema ASP MVC Entity Framework Posted by Alex Peta on February 19 2012 Building a Tracking Pixel in ASP MVC ASP MVC C Entity Framework Posted by Alex Peta on January 10 2012 Thinking On New Years Resolution vs Past Years Achievements Personal Posted by Alex Peta on December 31 2011 Secret Santa Random List Generator using CSharp Net ASP

    Original URL path: http://www.alexpeta.ro/blog/archive/5 (2016-05-01)
    Open archived version from archive

  • Entity Framework and DBO Schema
    it was tricky When you have always though that building an application starts with designing the database the data structures and the table mappings and to change all of that to just you model classes and leave all the under the hood stuff for EF s free will was a scary thing After building a so called alpha version of the blog v2 this one that you are viewing right now enthusiasm got the best of me and decided to publish it Upon trying this i realized a couple of things I did not use a connection string declaration in my Web config file for the Database This is translated to Entity Framework creating a database for me in my SQL Express instance Because i wouldn t didn t make any configurations to my models using Data Annotations or Fluent API EF used the default DBO database schema I exported the database objects from my SQL Express instance and checked the code My hosting schema user is administrator so i realized that i had to change the schema when it was time to move to production It was as simple as FIND and REPLACE in Notepad dbo with administrator All

    Original URL path: http://www.alexpeta.ro/blog/post/entity-framework-and-dbo-schema (2016-05-01)
    Open archived version from archive

  • Building a Tracking Pixel in ASP MVC
    ASP MVC this can be translated to a Action Method that returns FileStreamResult I have build a very basic project just for the sake of example using a small Superman logo The Track action method is the following public FileStreamResult Track int id our image stored in the Img folder var image new Bitmap Server MapPath Img superman gif the counting logic for this example i will write a file in the image folder for each view StreamWriter w new StreamWriter Server MapPath Img id txt w Close create a new memory stream MemoryStream stream new MemoryStream save the image in the stream image Save stream ImageFormat Gif This will rewind the stream to the beginning of the saved image Otherwise the stream will be positioned at the end of the stream and nothing is sent to the receiver stream Seek 0 SeekOrigin Begin return the filestreamresult return new FileStreamResult stream image gif This is very usefull if you have the requirement for metrics on newsletters email for any given project The whole purpose of what we wrote about here is to get a link that we will use as the src attribute for a img tag in a newsletter for example i e img src http localhost 1234 home track 1345 alt This is translated to when the client sends a GET to the server via this link it will trigger the counting logic and then it servers the tracking pixel UPDATE As Andrei suggested I could have made a HTML helper method to call the pixel generation instead of writing it each time Let me do this now A HML helper is basically a extension method of the HtmlHelper class and an extension method is basically a static method in a static class that has the first parameter

    Original URL path: http://www.alexpeta.ro/blog/post/building-a-tracking-pixel-in-asp-mvc (2016-05-01)
    Open archived version from archive

  • Thinking On New Years Resolution vs Past Years Achievements
    summarize and learn from the passing year and step in 2012 with the whole 2011 s worth of wisdom Globally a lot of things happened in 2011 and for me personally 2011 it has been a good year From a Programmers point of view 2011 ment for me Starting learning ASP MVC Reading a couple of NET books Finishing freelance work on http mp books ru Fianlly starting work on http www alexpeta ro Creating my own small blog CMS as part of the learning ASP MVC process psssst its this site that you are using right now Blogged a litte Did some interesting proje cts work Started Twitting Went to a couple of NET conferences but it wasn t all just about programming Travelled a bit Greece Thassos Met a lot of interesting and smart people who became my friends Worked out as much as i could keep up with the schedule Tryied to party as much as i could generally enjoyed myself These are just the first things that popped into my head You can sum all these up in just a couple of rows and you start thinking that maybe you should had done more Though one

    Original URL path: http://www.alexpeta.ro/blog/post/thinking-on-new-years-resolution-vs-past-years-achievements (2016-05-01)
    Open archived version from archive

  • The Mentality for hitting the Gym
    After a couple of years in junior high i started playing Basketball and it stuck with me all through highschool and a little in my first year of College I love this game Beeing in College in Bucharest i didn t have time to go anymore to hit the basketball field nor were the my old friends allways available for a match so at this point i had to do something else and then came the answer go to the gym When i first stepped foot in a gym i was weighing about 60KG 130punds for all you non metric people 180 eathing one meal two the most per day could even do a flat Bench Press with no weights It was a underground gym located in a huge empty room at a subway station near where i was living at that time I ve later learned that this is the place where the guys that go to bodybuilding competitions were training The first days weeks were awkword i didnt knew anything i just moved the weights around trying to mimic the other bulked up guys there It was hard really hard trying to integrate gym after work but after

    Original URL path: http://www.alexpeta.ro/blog/post/the-mentality-for-hitting-the-gym (2016-05-01)
    Open archived version from archive

  • Archive
    Images Create a Selfexpanding Textarea using Javascript Javascript CSS HTML XHTML Posted by Alex Peta on November 06 2011 Adding Gravatar To An ASP MVC Project ASP MVC C Posted by Alex Peta on October 28 2011 The Blog Is

    Original URL path: http://www.alexpeta.ro/blog/archive/6 (2016-05-01)
    Open archived version from archive



  •