Cannot see Widget in Internet Explorer 7 - c#

Im at my wits end trying to find a problem with a html/javascript page that acts like a widget that wont load in ie6 or ie7.. Would anyone be able to point me in the right direction on this?
http://cdn.xas.com/SampleOutput.html
Im guessing its some problem with some of my javascript?
I am building up the html in javascript, it could also be the html thats generated from this yes?
thanks
Neil

There are no offers displayed as dataCollection.Offers passed into function core.createOffersList, sourced from this.eventData in the BoonCentral.Com.Cdn.Widget, class is an empty array. As assigned by line 494:
this.eventData = {"Address":"10 Wellington Quay Jamestown, Dublin","ID":48,"LogoUrl":"http:\/\/www.booncentral.com\/VenueImages\/48\/201209171247\/0e8ed5bd-6076-4b67-a96a-5365cf225636the_workmans_club_dublin_28659.gif","Name":"The Workmans","Offers":[],"VenueProfile":"<p> <\/p><p>Dublin's most excellent new live music venue, situated in the heart of \u000d\u000athe city and open Monday to Sunday from 5pm til, well, when we kick you \u000d\u000aout!<\/p>"};
For IE6, you may be hitting this issue: http://kmleeblog.wordpress.com/2011/07/20/document-createelement-problem-in-ie6/
Hope this helps you narrow down the problem :-).

Although this doesn't answer your question- Why are you trying to make it work on IE6/7 ?
IE6 & 7 are barely used and are being phased out.
You're better off spending your time optimizing for current browsers..
According to http://www.theie7countdown.com/, the worldwide usage of IE7 is 4%.
According to http://www.w3schools.com/browsers/browsers_explorer.asp , it's now less than 1%.
With regards to this specific widget/project, is it taking you more than 1-4% of your time to address this issue?
Just my thoughts...

Related

Unity and iOS: line inside an "if" always running, no matter the condition

I have been dealing with this odd issue for a couple of days and I am really out of ideas.
I am programming in Unity for iOS. Here is the troubled fragment of code:
if (!aux.IsDownloaded())
{
aux.restoreTransaction();
aux.DownloadItem();
}
The really strange issue is that aux.DownloadItem() is always executed. It doesn't matter if the condition is true or false. If the condition is true, it shouldn't go inside the 'if', but it does! It just skip the first line (restoreTransaction) and runs the second one (DownloadItem). If the condition is false, it just runs normally.
I have tried several things in order to discover something more:
If I comment the DownloadItem line, the debugger shows that it runs the restoreTransaction line no matter the value of the condition, but it is really running the DownloadItem, since the downloading takes place.
If I replace the restoreTransaction line with any other expression (in my case, 15 lines of Debug.Log("ARGGG")), it just skip all of them and run the DownloadItem line.
I am really lost. I thought that it could be a data corruption, so I deleted the Library folder in my Unity project and cleared Monodevelop cache, but it keeps doing this weird thing.
I don't know what else to try. Any ideas would be welcome, please just drop any guess no matter how stupid it sounds in your heads, since I am really out of ideas, and at least I would like to keep trying.
EDIT: After some more test, there is clearly a difference between what the device is running and what I am debugging in monodevelop. Maybe a an issue from Unity 3D generating the xCode project?
This is by far the weirdest thing I have ever found.
Kind regards,
Aernarion
Welcome,
(I can't write comment, because of my reputation, so if this not helps just delete answer)
It's not a real solution, but as you wrote:
just drop any guess no matter how stupid it sounds in your heads
What about changing the last line? You tried to fill the code with junk ABOVE the problematic part. It seems if the statement is true, then runs the last line... If I'm right, then you can insert a new line AFTER, like Debug.Log("WEIRDPROBLEM").
Hope it helps, and sorry for bad eng and "not to comment",
RAPTOR
Most likely it's just an issue with a debugger and your code is fine. You can make sure of it by logging the result of aux.IsDownloaded(). Something like:
bool downloaded = aux.IsDownloaded();
Debug.Log(downloaded);
if (downloaded) {
...
}
If correct value is logged and your debugger is stepping in the wrong lines, then either you're hitting a corner case in the debugger, or debugger meta data for the assembly is out of sync for some reason.

Regex extract first +- n Characters but also include the rest of the charactes until the end of the line

Please help:
I have the following expression that retrieves the first 1000 characters of a string up until the end of the word, however I would like it to grab the text up until the end of the line (\r\n)?
Expression:
System.Text.RegularExpressions.Regex.Match(mystring, #"^.{1,1000}\b(?<!\s)").Value
Example text:
Whoo Hoo!! We made it through another year. Can you believe it? I can
hardly contain myself. This has been one bumpy ride. And now all of
that is over.\r\n\r\n Being a Taxi Driver can be quite rewarding in
more ways than one. There is nothing like it in the world!\r\n\r\n I
made some new friends and caught up with a couple old ones. I met new
people from all over the world and experienced a garden variety of
situations, all over a 12 hour period. \r\n\r\nTonight I had lots of
fun, though I can't help but to think of how disappointing it was for
everyone, financially, this year. I can remember a time when we would
have all booked and taken home about 3-4 times more than we did over
the past day. Buddy is my best friend. He is a small, blond, six and a
half year old Pekingese. He has been part of the family since he was
only three months old. He rode along on the front passenger seat as
one set of passengers came and went. watching intensely out the window
and paying close attention to where we were going and where we were
at. He would check out each person who entered the cab
(Currently it grabs the text till here)
just by looking at them over. He was enjoying his New Year!\r\n\r\n
(I would like it to Grab the text until here)
Around 1:30 AM I was crossing Ocean Blvd. A van ran out in front of
me. I slammed on the breaks and avoided a collision. Buddy was not
buckled in. His entire body slammed into the dash board and then he
dropped into the floor board. He was shaken and scared. Heck, I was
too. I was afraid that he was injured worse than the bump on his head
and his upset nervous system. It was at this moment I decided that it
was time for Buddy to go home and rest. I was glad that the dash is
built so high, otherwise Buddy would have met the wind shield.\r\n\r\n
You see, I feel like everything happens for a reason. At one moment my
mind started spinning, only lasting for a few seconds, and I realized
the there was a good reason I must have been sent to pick up each and
every one of the people whom I did this night. I set out each day with
a mission. Today I'll be in the right place, at the right time, to
meet the right people, for the betterment of all. \r\n\r\n 'I see
opportunity in every challenge.' \r\n\r\n This day did not short
change me on challenges, this is for sure. I know that I didn't do as
well as others, but did better than others. It seems, according to the
statics, that I may have faired out average. Over all I did well if
you ask me. Just look at the big picture. Note: This is not the order
of events of the evening.
"^(?<text>.{1,1000}[^\\]*)\\r\\n"
should work as it finds the corresponding \r\n, but only captures the text you want into the group "text".
No regex needed. Try
mystring.Substring(0, mystring.LastIndexOf("\r\n", 1000));
\r and \n are special "characters" in regex, respectively for, as you may expect, carriage-return and line-feed; so: let your regex scan until \r\n

Shortest encoding, Hexadecimal

Hi guys i would like to send the shortest possible string/value.
If i have the following
1)l23k43i221j44h55uui6n433bb4
2)124987359824369785493584379
3)kla^askdjaslkd3AS423$#ksala
What is the terminology for shortening strings,
Encoding? Encrypting?
At the same time, what is the best method to shorten a string of text, taking into consideration that i have only sms 255 limit
So my first day in prison I was taken to the mess hall for lunch, and I was sitting with a bunch of old guys who had been there for years. One of them stood up and yelled "51!" and sat down, and everyone laughed. A few minutes later another inmate stood up and yelled "96!" and again, everyone laughed.
I asked the old guy next to me what was going on and he explained that they had heard each other's jokes so many times that they had just made a list of them, numbered them, and yelled out the number to save the time of actually telling the joke.
So I stood up and yelled "23!"
Silence.
I sat down.
"Well, some people just aren't good at telling jokes I guess" said the old guy.
If you know in advance the strings that you're going to send, you can distribute a list of them ahead of time, and then just send the number of the string.
The term you're looking for is compression. Basically, you transform input data into output data that is shorter or of the same length. This will usually work for patterns and repetitions in the data (something like abcabcabc) or for a limited alphabet (like in your second example).

How to implement Stack Overflow's "are you a human" feature?

On this site if you do too many clicks or post comments too fast or something like that you get redirected to the "are you a human" screen. Does anybody know how to do something similar?
It's almost certainly a heuristic that tries to "guess" that a user is some form of automated process, rather than a person, for example:
More than "x" requests to do the same thing in a row
More than "x" actions in a "y" period of time
Ordinarily the "x" and "y" values would be formulated to be ones that it would be unlikely for a "real person" to do, like:
Editing the same answer 5 times in a row
Downvoting 10 questions within 1 minute
Once you've got your set of rules, you can then implement some code that checks them at the start of each request, be it in a method that's called in Page_Load, something in your masterpage, something in the asp.net pipeline, that's the easy bit! ;)
Here is a very nice Captcha Control for asp.net that first of all you need
http://www.codeproject.com/KB/custom-controls/CaptchaControl.aspx
Then you can use it together with this idea that try to find the dos attacks
http://weblogs.asp.net/omarzabir/archive/2007/10/16/prevent-denial-of-service-dos-attacks-in-your-web-application.aspx
be ware of a bug in this code in line if( context.Request.Browser.Crawler ) return false;, its must return true, or totally remove it for sure.
and make it your compination for the clicks, or submits.
If a user make too many clicks on a period of time, or many submits, then you simple open the capthaControl, and if the clicks are by far too many, then triger the dos attact. This way you have 2 solution in one, Dos attact prevent, with captcha at the same time.
I have made somthing similar my self, but I have change the source code of both, a lot to feet my needs.
One more interesting link for a different code for the dos attack.
http://madskristensen.net/post/Block-DoS-attacks-easily-in-ASPNET.aspx
Hope this help you.
At a guess...
Write a HTTP handler that records requests and store them in session.
When a new request comes in, check to see how many requests are stored (and expire old ones).
If the amount of requests in the past few minutes exceeds a given threshold, redirect the user.
If you're doing this in ASP.NET webforms, you could do this check on the site master page, ( or write a IHttpHandler).
If you're using an MVC framework, you could write a base controller that does this check for every action.
With rails, you could write a before_request filter.
With asp.net MVC, you could write a [ActionFilterAttribute] attribute
You should have a session to track the user activity.
In session you can have counter for commenting and posting like:
(pseudo code instead of C#, sorry :)
if (post_event) {
posts_during_1_minute_interval++;
if (time_now-reference_time > 1_minute) {
reference_time = time_now;
posts_during_1_minute_interval=0;
}
}
...
if (posts_during_1_minute_interval > 10) redirect("/are-you-human.htm");
where on are-you-human.htm page you can have recaptcha, as they have here on StcakOverflow.com
see also:https://blog.stackoverflow.com/2009/07/are-you-a-human-being/
just check how many hit / minutes you get from a specific ip or session or whatever and decide what are your preferred threshold and your good to go
I'd also check the user agent header of the request - if it doesn't look like a popular browser (or is empty) then throw the "are you a human?" page.

System constant for the number of days in a week (7)

Can anyone find a constant in the .NET framework that defines the number of days in a week (7)?
DateTime.DaysInAWeek // Something like this???
Of course I can define my own, but I'd rather not if it's somewhere in there already.
Update:
I am looking for this because I need to allow the user to select a week (by date, rather than week number) from a list in a DropDownList.
You could probably use System.Globalization.DateTimeFormatInfo.CurrentInfo.DayNames.Length.
I think it's ok to harcode this one. I don't think it will change any soon.
Edit: I depends where you want to use this constant. Inside the some calendar related algorithm it is obvious what 7 means. On the other hand sometimes named constant make code much more readable.
Try this:
Enum.GetNames(System.DayOfWeek).Length
If you look at the IL code for Calendar.AddWeeks you will see that Microsoft itself uses a hardcoded 7 in the code.
Also the rotor source uses a hardcoded 7.
Still, I would suggest to use a const.
I used this:
public static readonly int WeekNumberOfDays = Enum.GetNames(typeof(DayOfWeek)).Length;
I don't believe there is one. TimeSpan defines constants for the number of ticks per milli/second/minute/hour/day, but nothing at the level of a week.
I ran a query across the standard libraries for symbols (methods/constants/fields/etc) containing the word 'Week'. Nothing came back. FYI, I ran this query using ReSharper.
I'm not sure what exactly you're looking for, but you can try DateHelper (CODE.MSDN). It's a library I put together for typical date needs. You might be able to use the week methods or the List methods. method list
Edit - no more MSDN code, not on GitHub as part of lib: https://github.com/tbasallo/toolshed
Do you mean calendar weeks or just common weeks?
Obviously, there are calendar weeks that might be shortrer than seven days. The last calendar week of the year is usually shorter, and depending on your definition of calendar week, the first week might be shorter as well.
In that case, I'm afraid you will have to roll out your own week length function. It's not really hard to do with the DateTime class, I did it before, if you need more help let me know.
GregorianCalendar has AddWeeks(1) which will add 7 days to a date.

Categories

Resources