‏إظهار الرسائل ذات التسميات using. إظهار كافة الرسائل
‏إظهار الرسائل ذات التسميات using. إظهار كافة الرسائل

الأحد، 5 يناير 2014

How to perform innner Join on Five Tables using Linq

Are the types of your expression variables the same? E.g.: are c.GroupId and g.GroupId both int or is one of them of type byte?

The types of the variables in your expressions must be of the same type if you want to compare them with each other.


View the original article here

الثلاثاء، 24 ديسمبر 2013

How to replace text between two XML tags using jQuery or JavaScript?

I have a XML mark-up/code like the following. I want to replace the text inside one of the tags (in this case ...) using JavaScript or jQuery.

A new beginning Stuff here...

The source is inside a textarea. I have the following code, but it is obviously not doing what I want.

code=$("xml-code").val(); // content of XML sourcenewBegin = "The same old beginning"; // new text inside tagsnewBegin = ""+newBegin +""; code=code.replace("",newBegin); // replace content

This is just appending to the existing text inside the begin tags. I have a feeling this can be done only using Regex, but unfortunately I have no idea how to do it.


View the original article here

merge Array using Function in PHP

I am new to PHP programming and i want to do this functionality using php coding style. I have a two integer array and i want to merge it in to a single array without using any built in php function.Simply i want one function and i will pass the both array as a parameter and then after processing it will show the third array as a combine of that both.

$array1=array('11','12','13','14','15');$array2=array('21','22','23','24','25');

So how i will achieve this functionality?


View the original article here

الجمعة، 20 ديسمبر 2013

If Web API can be used just for Authentication using OAuth 2 in ASP.NET MVC4

I'm working on segregating the authentication part of my ASP.net MVC4 application using DotNetOAuth 2.0, Which will means that one project will do only authentication and send out response,based on response it will have access to other application.

The Idea is to get any application or project added later on use one common authentication process.

First thing came to my mind was building a service, in the process a read a lot about Web API and think it can help to achieve what I'm looking for.

Please suggest if you guys have implemented something like this or whats's the best practice.

Should i go with API or service, any link or sample to direct is appreciated


View the original article here

Posting status automatically using graph with url provided

I'm using actual Facebook iOS SDK and trying to post status update, with url provided.

So far I managed to post simple text status using:

[connection addRequest:[FBRequest requestForPostStatusUpdate:message] completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {// [self showAlert:message result:result error:error]; }]; [connection start];

I tried to modify it so, the url would be attached and did it like this:

[connection addRequest:[FBRequest requestForPostOpenGraphObjectWithType:@"RG Training" title:@"Test Title" image:nil url:@"http://runguru.pl" description:@"Test description" objectProperties:nil] completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { if (error) [self.appDelegate showUnknownCommunicationError];}];[connection start];

Unfortunately this causes error:

Error Domain=com.facebook.sdk Code=5 "The operation couldn’t be completed. (com.facebook.sdk error 5.)" UserInfo=0x15f7c010 {com.facebook.sdk:ErrorInnerErrorKey=Error Domain=NSURLErrorDomain Code=-1000 "bad URL" UserInfo=0x15fc53f0 {NSUnderlyingError=0x15eec120 "bad URL", NSLocalizedDescription=bad URL}, com.facebook.sdk:HTTPStatusCode=200, com.facebook.sdk:ErrorSessionKey=, expirationDate: 2014-02-18 09:32:00 +0000, refreshDate: 2013-12-20 09:36:53 +0000, attemptedRefreshDate: 0001-12-30 00:00:00 +0000, permissions:( "photo_upload", "basic_info", "video_upload", "share_item", "publish_stream", installed, "user_friends", "status_update", "public_profile", "create_note", "publish_actions")>}

Error says there is something wrong with URL, but what?


View the original article here

Cannot find element using simple_html_dom.php

This is the script I am using:

find('#title'); echo count($title);?>

count($title) returns 0.

There is indeed a line in the web page

Folding Helping Hand Long-Reach Pick-Up Gripper - 26" Aluminum

but the simple_html_dom script cannot find it.

I have also tried

$title = $html->find('h1[id=title]');

but count($title) still returns 0.

I run

echo $html->plaintext;

and the title is there.

I have no idea what the problem is.

Any help is appreciated!

Edit:

I notice that stackoverflow somehow change my url after I save the post.

This is the correct function call: file_get_html("http://rads.stackoverflow.com/amzn/click/B000VS8CTM").


View the original article here

Unit testing using two functions

I've neglected unit testing for some time. I wrote unit tests, but they were fairly poor. I'm now reading through "The art of unit Testing" to bring myself up to scratch.

If I have an interface such as:

public interface INotificationService{ void AddError(string _error); void AddIssue(string _issue); IEnumerable FetchErrors(); IEnumerable FetchIssues();}

A concrete implementation of this interface contains:

private readonly ICollection messages;

Adding an error or issue creates a new message with an enum denoting it's type and adds it to the collection. Calling FetchErrors() / FetchIssues() returns messages of that type from the collection.

Would the following test be valid?:

[Test] public void FetchErrors_LoggingEnabledAddErrorFetchErrors_ReturnsError() { notificationService = new NotificationService(); notificationService.AddError("A new error"); Assert.AreEqual(new []{"A new error"}, notificationService.FetchErrors()); }

My concern is that I'm first calling AddError(), then testing the result of FetchErrors(). So I'm calling two functions. Is this incorrect?

Should I make the collection public and directly assert that it contains a message of the appropriate type containing the logged error message?

What would be the best practice in this scenario?


View the original article here