jQuery append() IE error

by OfirYaron 1/5/2011 2:18:00 AM

I'm developing most of my web application using firefox, (it's much easier and there's no match for the FF-FireBug), before I check-in my changes I usually check the new pages on the other major browsers and most of the times there are only a few CSS isuues that easlly resolved, 

JS or jQuery for that matter never gave me problem on none of the other browsers EXCEPT IE!

In IE it turns out that the $.append() attribute won't replace contents , I though a could build a little work-around by using $.html() but ended up with the same result,

finally I figured it out, It seems that IE ignore the DOM injection if the HTML I'm tring to append is invalid (i.e. opening and closing tags match).  I guess it makes sence, but I still hate this browser!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

jQuery

Hosting WCF service with GoDaddy

by OfirYaron 6/9/2010 11:09:00 AM

Shared hosting it a big pain in my A**,
I've been trying (unsuccessfully) to upload an WCF service to my GoDaddy hosting account,

At first i've got good old:
500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

this error usally hide another a site exception that can be revealed by adding:
<httpErrors errorMode="Detailed"/> under
<system.webServer>
after dealing with that i've discovered the real error is due to duplicated web.config keys with GoDaddy's machine.config
the keys are

<modules>
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>

That was solved by removing GoDaddy's key with pre-remove tags for each add tag like so:

<modules>
      <remove name="ScriptModule"/>
      <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</modules>
<handlers>
      <remove name="ScriptHandlerFactory"/>
      <remove name="ScriptHandlerFactoryAppServices"/>
      <remove name="ScriptResource"/>
      <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
      <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</handlers>

after that issue, I discovered that Godaddy doesn't recognize WCF service extension (.svc) and i'm getting the following error:

There is no build provider registered for the extension '.svc'. You can register one in the <compilation><buildProviders> section in machine.config or web.config. Make sure is has a BuildProviderAppliesToAttribute attribute which includes the value 'Web' or 'All'.

so to solve that i tried adding the extension my selfe by adding the following in the web.config under <system.web>:


<compilation>
      <buildProviders>
        <add extension=".svc" type="System.ServiceModel.Activation.ServiceBuildProvider,
         System.ServiceModel, Version=3.0.0.0, Culture=neutral,
         PublicKeyToken=b77a5c561934e089"/>
      </buildProviders>
</compilation>

only that took me back to 500 error,
I finally broke down and (no I did not cry) contact My beloved hosting company only to find out that they do not support WebServices.

If for any reason this post came up on your search and you're at step one...
walk it off - there isn't any known way of making WCF work on Godaddy Hosting account,
I've spent 4 hours learning it the hard way :(

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SubSearcher 1.5

by OfirYaron 5/21/2010 10:46:00 PM

I made a few adjustments with the SubSearcher previous version, instead of directing you to a results page on the browser it now contained with a built in Subtitle version selection Form as displayed below:

Pressing the download button will download the file directly to the movie’s folder.

The next version will extract the downloaded file automatically and show you better info about the selected movie, also the tool will be added with a Setting page.

Download SubSearcher (v1.5)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Subtitle Searching Tool

by OfirYaron 5/15/2010 4:15:00 AM

I finally set down for a couple of hours and started working on this thing I’m thinking on for a few weeks now – Automatic Subtitle Searcher.

The idea came to me thanks to my wife that always encounter with problems trying to find a matching subtitle file to a (Legally) downloaded movie, sure… it’s pretty straight forward easy for us guys… but when it comes to selecting the most suitable version out of 10 option, taking into consideration the Codec version, Movie Ripper, number of parts and frame rate, it takes more than she understand and want to understand on the matter, so I end up finding the subtitles myself in the end.

The solution in my mind was a context menu that will pop up on .Avi file type that direct you to a subtitle search engine (pre customized at first) and out of the search results (If any) will download the best matching version considering Codec/Ripper/Frame rate/etc…

I must admit that I’m only starting to implement all features but I decided to share it at this early stage any way since it’s still easier then searching manually, Hopefully over the next week I’ll complete the rest and upload an improved version.

Right now it has an installer that adds a Context menu to .Avi files that direct you to the search result page (the tool searches the movie name after substracting the codec/ripper/year/etc…)

 

The upcoming versions will contain the following features:

1.       Find the best matching subtitle according to codec/ripper/frame rate and downloading it automatically to the movie’s directory

2.       Setting page for selecting more than one subtitles resource

3.       Automatically update the tool on a new version without reinstalling

4.       Preview after download, re-download other version if doesn’t match

I’ll be happy to receive any ideas for new features, and of course contact me if you encounter with any bug.

Download SubSearcher

Cheers.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

SEO oriented programming. (Part 1)

by OfirYaron 2/1/2010 9:45:00 AM

One of the most important things when publishing a website is exposure, there are many ways of bringing your site to public knowledge, advertisement is one of them, but a more basic and necessary way of doing so is optimizing the website to search engines. Without SEO planning and implementation your site may stay in the hidden web for a long time. 
As developers we encounter a wide range of SEO tools, some are free, some are pricy and many are open source and provide certain flexibility, referenced at the end are some of my favorites.
Most of these tools offer some good advices on a live site, but at that point, these changes are too costly to implement.
 
The first thing a good SEO'd (Yep, new word :) site needs is a Validated HTML. Invalid HTML may cost you on your page rank, such issues can be prevented beforehand while coding the HTML, so making sure you follow the W3C standard is preferred.
For example, a lot of GUI developers are not aware of the significance of… placing one  H1 per page or placing H tags in an incremental order.
Trying to fix such issues will take time and could result a massive change to the CSS and design…  sometimes produce even more bugs, as if the ones you already have are not enough.
 
Since implementing these changes or fixes is complicated after publishing a site, its mostly left undone.
Let's put down some ground rules to avoid this expensive refactoring:
 
1.  All the developers should be aware of SEO basics. Project managers are not the only ones to be concerned with promoting the site.
2.   Consult a SEO professional at the early stages of the project, allow them to code-review the HTML and fix the problems early (Or do-it-yourself and learn some SEO!).
3.  Use HTML validation tools as much as possible.
4.  Create sitemaps and make sure every page can be viewed without AJAX.


Tools:
Xenu - http://home.snafu.de/tilman/xenulink.html - Xenu's Link Sleuth (TM) checks Web sites for broken links and resolve page's meta data.
http://validator.w3.org/ - Single page HTML validation service.
http://tools.seobook.com/firefox/seo-for-firefox.html - SEO toolbar for Firefox.
http://tools.seobook.com – SEO help, the DOs and DON'Ts of SEO and plenty of tools to help you with SEO.

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

SEO

Linq with WCF

by OfirYaron 8/3/2009 7:51:00 AM

"An error occurred while receiving the HTTP response to
http://xxx/. This could be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by the server
(possibly due to the service shutting down). See server logs for more details."

Got this message while trying to communicate to a WCF service I’ve built,

My initial assumption was that I’m not using the suitable security binders at both sides (server and client) .

First thing I tried was striping down the authentication configuration to “none” – the same exception was still thrown.

Secondly I tried to remove the service functionality to most basic by returning null, It works, I’ve returned the functionality but kept returning null and guess what - still worked.

At this point it was clear that the is some problem with the object that I try to return, I assumed that my Linq to Sql objects were not Serialized, indeed that was the cause, if you’re having this exception and use Linq to Sql object as a returned object – Its probably it.

Here is a very helpful “how to” on the subject: http://www.west-wind.com/Weblog/posts/147218.aspx 

(All that need to be done is changing the DataContext Serialization Mode to Unidirectional)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

WCF

MVC ActionResult inheritance

by OfirYaron 7/19/2009 5:47:00 AM

MVC contains a nice class you can inherit inorder to return http responses other then a regular Render View:

bellow are three implementations I use the most:

ImageResult, TextResult and RssResult:

public class ImageResult : ActionResult

{

public Stream ImageStream { get; private set; }

public string ContentType { get; private set; }

public ImageResult(Stream imageStream, string contentType)

{

if (imageStream == null)

throw new ArgumentNullException("imageStream");

if (contentType == null)

throw new ArgumentNullException("contentType");

this.ImageStream = imageStream;this.ContentType = contentType;

}

public override void ExecuteResult(ControllerContext context)

{

if (context == null)

throw new ArgumentNullException("context");

HttpResponseBase response = context.HttpContext.Response;response.ContentType =

this.ContentType;

byte[] buffer = new byte[4096];

while (true)

{

int read = this.ImageStream.Read(buffer, 0, buffer.Length);

if (read == 0)

break;

response.OutputStream.Write(buffer, 0, read);

}

response.End();

}

}

public class TextResult : ActionResult

{

public string Content { get; private set; }
public TextResult(string content)

{

this.Content = content;

}

public override void ExecuteResult(ControllerContext context)

{

if (context == null)

throw new ArgumentNullException("context");HttpResponseBase response = context.HttpContext.Response;

response.Write(Content);

response.End();

}

public class RssResult : ActionResult

{

public SyndicationFeed Feed { get; set; }

public RssResult() { }

public RssResult(SyndicationFeed feed)

{

this.Feed = feed;

}

public override void ExecuteResult(ControllerContext context)

{

context.HttpContext.Response.ContentType =
"application/rss+xml";

Rss20FeedFormatter formatter = new Rss20FeedFormatter(this.Feed);

using (XmlWriter writer = XmlWriter.Create(context.HttpContext.Response.Output))

{

formatter.WriteTo(writer);

}

}

}

Currently rated 5.0 by 3 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

MVC

Saving objects to the registry

by OfirYaron 4/27/2009 7:49:00 AM

I've needed a way to save a complex object to the registry so I've wrote this class,

basically it uses reflection in order to find the properties of a generic type that was given and fill them in with the matching (by name) key on the registry.

public class RegistrySmartAgent

{

public string BasePath { get; private set; }public RegistrySmartAgent(string basePath)

{

BasePath = basePath;

}

private T ReadSingle<T>(string fullPath) where T : new()

{

RegistryKey key = Registry.LocalMachine.OpenSubKey(fullPath);

T t = new T();

foreach (string name in key.GetValueNames())

{

Type typeInfo = typeof(T);

PropertyInfo propertyInfo = typeInfo.GetProperty(name);

if ((propertyInfo != null) &&

(propertyInfo.PropertyType == typeof(int)) ||(propertyInfo.PropertyType ==

typeof(string)) ||

(propertyInfo.PropertyType == typeof(double)))propertyInfo.SetValue(t, key.GetValue(name),

null);

}

return t;

}

public IDictionary<string, T> Read<T>(string subName) where T : new()

{

RegistryKey key = Registry.LocalMachine.OpenSubKey(BasePath + "\\" + subName);

IDictionary<string,T> retList = new Dictionary<string,T>();

foreach (string name in key.GetSubKeyNames())

{

retList.Add(name,ReadSingle<T>(BasePath +
"\\" + subName + "\\" + name));

}

return retList;

}

public bool Write<T>(string subName, T element)

{

Type typeInfo = typeof(T);

PropertyInfo[] properties = typeInfo.GetProperties();

foreach (PropertyInfo propertyInfo in properties)

{

RegistryKey key = Registry.LocalMachine.OpenSubKey(BasePath + "\\" + subName);

if (key==null)key =

Registry.LocalMachine.CreateSubKey(BasePath + "\\" + subName);key.SetValue(propertyInfo.Name, propertyInfo.GetValue(element, null));

}

return true;

}

}

Currently rated 4.5 by 2 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , ,

Sanitize YouTube embed objects

by OfirYaron 4/20/2009 5:56:00 AM

It's contributing alot to a blog or a site when one allows embedding youTube videos to the posts or comments,

the real down-side is that by doing so you have to take into considiration the breach of cross side scripts that the object tag allows.

so for that matter I wrote a Regular expression that validate the input and retrive the URL from within the embed tag, then I placed it on a template tag that I know is safe,
By doing so you can even control the panel color and size that best suit you site.

here is how it works:

private string SanitizeYouTubeObject(string input)

{

//You Tube object Regular Expression

Regex youTubeObjExp =

new Regex(

@"(<embed\ssrc=""http://www.youtube.com(?<Url>[\w\d\s\p{L}\p{S}:#@%/~_?\+-=\\\.&’]+(?=""))([\w\d\s\p{L}\p{S}:""#@%/~_?\+-=\\\.&’]+)(></embed>))",

RegexOptions.IgnoreCase);

if (youTubeObjExp.IsMatch(input))

{

Match match = youTubeObjExp.Match(input);

string videoObject = string.Format(

@"<object width=""480"" height=""385""><param name=""movie"" value=""{0}""></param><param name=""allowFullScreen"" value=""true""></param><param name=""allowscriptaccess"" value=""always""></param><embed src=""{0}"" type=""application/x-shockwave-flash"" allowscriptaccess=""always"" allowfullscreen=""true"" width=""480"" height=""385""></embed></object>", "http://www.youtube.com" + match.Groups["Url"].Value);

//Return the sanitized Tag

return videoObject;

}

//In case it wasn't a legit Object Tag

return null;

}

 

its a simple example only to pass the idea.

A real generic solution will take a dictionary of known embed regexs (youTube, MySpace, etc...) and sanitize any given input accordinly, that way you allow a closed list of well know sites and the DB doesn't have to store the entire tag, the URL will be enough.

Currently rated 4.5 by 4 people

  • Currently 4.5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Pagination on Linq to SQL

by OfirYaron 3/15/2009 5:49:00 AM

Paging on linq is so much easier then anything I've ever worked with.

consider the following code to add a generic GetPage method in case you use it on several Data Entities in your application:

public static T[] GetPage<T, K>(System.Data.Linq.Table<T> tableObject,

System.Linq.Expressions.Expression<Func<T, K>> orderPred,

int pageSize, int selectedPage) where T : class, new()

{

return tableObject.OrderByDescending(orderPred).Skip(pageSize * (selectedPage - 1)).Take(pageSize).ToArray();

}

public static void Test()

{

// Say this is my Users table:

//User(1,"Ofir")

//User(2,"Yaron")

//User(3,"Danny")

//User(4,"Gila")

//User(5,"Ran")

//User(6,"John")

//User(7,"Marry")

//User(8,"Shay")

//User(9,"Shula")

//User(10,"Moish")

//getting the second page - 4 objects

User[] point = GetPage<User, int>(Utilities.DB.Users, u => u.Id, 4, 2);

//returns:

//Ran

//John

//Marry

//Shay

}

 

Currently rated 4.6 by 5 people

  • Currently 4.6/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: , , ,

Powered by BlogEngine.NET 1.3.0.0
Theme by Mads Kristensen

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Recent posts

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012

Sign in