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".
  • Welcome to AlexPeta.ro
    agile games and more Vintage Fashion and Non Recursive Hierarchical SQL Queries C Fashion Vintage Hierarchical SQL Modeling Posted by Alex Peta on November 29 2013 Localizing your Views in ASP MVC ASP MVC C Posted by Alex Peta on June 27 2013 Calculating the Distance Between two GPS Coordinates C Posted by Alex Peta on March 02 2013 My First Windows Phone App Location Based Notifications Part 1 C

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


  • About Me
    work from downtown Bucharest Romania and I blog not as much as I would like here All content and opinions expressed are solely mine Throughout the years I did couple of different jobs a few smaller ones during my studies like in a callcenter as a Collection Officer and a Business Analyst at a multinational company after which I started my career with several programming roles on different technologies including

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

  • Contact
    Me Have questions I have answers maybe Copyright from Bing images North Window Arch in Arches National Park Utah  Clarence Spencer Currently the contact form is offline Try reaching out to me via my social media accounts Name Email

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

  • Vintage, Fashion and Non Recursive Hierarchical SQL Queries
    saw the implementation I felt like discovering a piece of gold inside a piece of crap dirt Here is our example hierarchy a simple basket that has fruits and vegetables in it The result that we want to achieve is to get a sub tree from this large tree as quickly as possible and not recursively The answer pre compute the data before inserting it into a different representation then the parentId foreign key usual representation Now its time to mark all the nodes by doing a Depth first search in the tree by adding 2 values for each node left side index meaning start point right side index meaning leaving point Here is the tree after it has been marked Let s see how our end result table will look like with the data inserted from the marked tree Name LeftIndex RightIndex Basket 1 16 Fruits 2 9 Apple 3 4 Cherry 5 6 Banana 7 8 Veggies 10 15 Tomato 11 12 Onion 13 14 Now lets see some queries in action Get all the fruits sub tree SELECT LeftIndex as start RightIndex as end FROM table where Name Fruits SELECT FROM table WHERE LeftIndex start AND RightIndex end First I am getting the startIndex left and endIndex right for the subtree that I want to retrieve and then I am doing the actual query just by comparing values that are in my expected interval And we can continue like this to get all the sub trees that we want you got the big picture Now lets write some code that will represent our tree in C We will need a node first of all namespace NonRecursiveHierarchicalSQLQueries DataStructures Concrete public class Node T where T INode region Properties public int LeftIndex get set public int RightIndex get set public T Value get private set public List Node T Children get private set endregion Properties region Constructors public Node T nodeValue this Value nodeValue Children new List Node T endregion Constructors region Public Methods public virtual void InsertChild Node T child Children Add child public void MarkTree ref int index LeftIndex index foreach var child in this Children child MarkTree ref index RightIndex index public void Visit Action Node T action action this foreach var child in Children child Visit action endregion Public Methods This is a quick generic implementation of a tree node It has a Value property that can be any T where T is an INode and also 2 more numeric properties LeftIndex and StartIndex that we are using to insert in our table columns in the database I ve also create a Mark method that is the method to call when marking each node and setting the left and right indexes And finally we have a Visit method that accepts a action with the current node and passes this action recursively to its children this is to offer different flexible actions to do on the tree Now lets use this generic node to create a

    Original URL path: http://www.alexpeta.ro/blog/post/vintage%2c-fashion-and-non-recursive-hierarchical-sql-queries (2016-05-01)
    Open archived version from archive

  • Localizing your Views in ASP MVC
    ResourceManagerHelper Assembly private static readonly object mSyncLock new object endregion Private Members region Constructors private ResourceManagerHelper static ResourceManagerHelper endregion Constructors region Public Methods public static ResourceManager GetResourceManagerInstance CallerMemberNameAttribute string resourceName null lock mSyncLock if string IsNullOrWhiteSpace resourceName mInstance new ResourceManager string Format 0 1 Constants NamespaceEnum CResourcesPartialNamespace resourceName typeof ResourceManagerHelper Assembly else mInstance new ResourceManager Constants NamespaceEnum CResourcesDefaultNamespace typeof ResourceManagerHelper Assembly return mInstance endregion Public Methods The interesing bit here is the GetResourceManagerInstance method that accepts the resource file name passes it to the ResourceManager constructor Another trick that is available in NET 4 5 is the CallerMemberNameAttribute parameter attribute that returns the calling method name I think behind the scenes its done by reflection I added this in case I would call this method directly in the ActionResult body and to add more flexibily Next I started work on a wrapper class around the default controller class This is the place that I will all the stuff that my views need to have access to and this will serve as the base controller for all my pages the ResourceManager and other stuff public class MVCBaseController Controller region Private Members private ResourceManager mResourceManager private IUnitOfWork mUnitOfWork endregion Private Members region Protected Properties protected ResourceManager ResourceManager get return mResourceManager set mResourceManager value protected IUnitOfWork UnitOfWork get return mUnitOfWork set mUnitOfWork value endregion Protected Properties region Constructors constructor injection for UnitOfWork implementation public MVCBaseController this new UnitOfWork public MVCBaseController IUnitOfWork unitOfWork UnitOfWork unitOfWork endregion Constructors region Overrides protected override void Initialize System Web Routing RequestContext requestContext base Initialize requestContext InitializeResourceManager endregion Overrides region Private Methods Method that initializes the resource manager based on the RouteData action method to get the appropriate resource for the currenct action view private void InitializeResourceManager string callingMemberName string Empty if RouteData null RouteData Values null var routeValue

    Original URL path: http://www.alexpeta.ro/blog/post/localizing-your-views-in-asp-mvc (2016-05-01)
    Open archived version from archive

  • Calculating the Distance Between two GPS Coordinates
    to pass to trig functions All I had to do migrate this in C and test it out I m going to this the fancy way around because I have been brainwashed with OOP A simple GPSPoint strunct that will hold the coordinates namespace AlexPetaBlog GPSDistanceCalculator public struct GPSPoint region Private Members private double latitude private double longitude endregion Private Members region Public Properties public double Latitude get return latitude set latitude value public double Longitude get return longitude set longitude value endregion Public Properties region Constructors public GPSPoint double latitude double longitude latitude latitude longitude longitude endregion Constructors region NullObject Pattern private static GPSPoint empty new GPSPoint 0 0 public static GPSPoint NullPoint empty endregion NullObject Pattern The GPSDistanceHelper class namespace AlexPetaBlog GPSDistanceCalculator This uses the haversine formula to calculate the great circle distance between two points that is the shortest distance over the earth s surface giving an as the crow flies distance between the points ignoring any hills of course public class GPSDistanceHelper region Private Members represents the radius of the Earth in KM private readonly int R 6371 private GPSPoint start private GPSPoint end private double distance endregion Private Members region Public Properties public GPSPoint Start get return start set start value public GPSPoint End get return end set end value public double Distance get return distance set distance value endregion Public Properties region Constructors public GPSDistanceHelper this GPSPoint NullPoint GPSPoint NullPoint public GPSDistanceHelper GPSPoint start GPSPoint end Start start End end CalculateDistance endregion Constructors region Statics public static double DegreesToRadians double degrees return degrees Math PI 180 endregion Statics region Private Methods private void CalculateDistance double dLat GPSDistanceHelper DegreesToRadians End Latitude Start Latitude double dLon GPSDistanceHelper DegreesToRadians End Longitude Start Longitude double lat1 GPSDistanceHelper DegreesToRadians Start Latitude double lat2 GPSDistanceHelper DegreesToRadians End Latitude double a

    Original URL path: http://www.alexpeta.ro/blog/post/calculating-the-distance-between-two-gps-coordinates (2016-05-01)
    Open archived version from archive

  • My First Windows Phone App Location Based Notifications Part 1
    INotifyPropertyChanged protected virtual bool IsValid throw new NotImplementedException As you can notice my base class implements as expected INotifyPropertyChanged as well as INotifyPropertyChanging it seems this is a good thing to do performance wise when it comes to WP8 namespace LocationBasedNotifications Table public class Location BaseModel region Properties private int locationId Column IsPrimaryKey true IsDbGenerated true DbType INT NOT NULL Identity CanBeNull false AutoSync AutoSync OnInsert public int LocationId get return locationId set locationId value private string name Column public string Name get return name set if name value return NotifyPropertyChanging Name name value NotifyPropertyChanged Name private double latitude Column public double Latitude get return latitude set if latitude value return NotifyPropertyChanging Latitude latitude value NotifyPropertyChanged Latitude private double longitude Column public double Longitude get return longitude set if longitude value return NotifyPropertyChanging Longitude longitude value NotifyPropertyChanged Longitude private string description Column public string Description get return description set if description value return NotifyPropertyChanging Description description value NotifyPropertyChanged Description Version column aids update performance Column IsVersion true private Binary version endregion Properties region Constructors public Location this string Empty 0D 0D string Empty public Location string name double latitude double longitude string description Name name Latitude latitude Longitude longitude Description description endregion Constructors This is the Location entity that inherits the above BaseModel As you noticed all of the public properties are are decorated with attributes from the System Data Linq Mapping namespace The reason for this is that Windows Phone 8 uses as persistent storage Linq to SQL via the DataContext on the isolated storage database Data Access Now we need to implement the DataContext and the repository interface contracts namespace LocationBasedNotifications Contracts public interface IRepository where T BaseModel IEnumerable GetInMemoryLocations bool AddItem T itemToAdd bool RemoveItem T itemToRemove void Save IEnumerable list The DataContext namespace LocationBasedNotifications Repository public

    Original URL path: http://www.alexpeta.ro/blog/post/my-first-windows-phone-app-location-based-notifications-part-1 (2016-05-01)
    Open archived version from archive

  • Archive
    SignalR RONUA Presentation Part 2 ASP MVC C SignalR Posted by Alex Peta on January 09 2013 Real Time web applications in ASP MVC 4 with SignalR RONUA Presentation ASP MVC C SignalR Posted by Alex Peta on December 31 2012 Bodybuilding and High Intensity Training Bodybuilding Posted by Alex Peta on December 06 2012 Exporting a Cangeset in Team Foundation Server TFS using Team Foundation Power Tools TFPT Part

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