This particular October only occurs every 823 years? Nonsense!

20121005-091305.jpg

I’ve seen this posted all over the place recently, and there was something similar for August back in 2010. It’s on Facebook in many forms, from many people and it’s being shared left right and centre.

Not in many places though do I see anyone calling it out, and saying, “That can’t be right?”

It’s a little distressing to see that a good 90% of the Internet just take it on face value that the 823 year claim is correct, and that it’s cool!!1!1!

Any given year can only have one of seven days that it starts on, so that gives a total number of 7 possible calendars, 14 if you include leap years. One of those 14 only gets used every 823 years? Really?

For October to have 5 Mondays, Tuesdays, and Wednesdays it just needs to start on a Monday, that doesn’t happen every 7 years though, because of leap years it goes in a 6 – 5 – 6 – 11 pattern. So the longest gap would be eleven years, a far cry from 823.

And as for the moneybags nonsense, well no need to connect I think.

Why are so many people willing to believe the claim, and pass it on without a moments thought? Is the Internet dumbing us down?

Simple ASP.net Role View Control

For a while now I’ve been wishing I didn’t have to do this…
[xml]
<asp :LoginView ID="LoginView1" runat="server">
<rolegroups>
<asp :RoleGroup Roles="Administrator">
<p>Admins only!</p>
</asp>
</rolegroups>
</asp>
[/xml]
…every time I want to have something only an Admin can see. It’s not that it takes long to do, it just seems incredibly inefficient.

So now my first custom control to the rescue, to this point I’ve only used user controls in ASP.net.

[csharp]
using System.Web.Security;
using System.Web.UI.WebControls;

namespace Teknohippy
{
public class AdminView : PlaceHolder
{
public AdminView()
{

}

public override bool Visible
{
get
{
if (DesignMode)
{
return base.Visible;
}
else
{
return base.Visible && Roles.IsUserInRole("Administrator");
}
}
set
{
base.Visible = value;
}
}
}
}

[/csharp]

Now I can just to the following instead…

[xml]
<tekno:AdminRole id="a1" runat="server">
<p>Admins Only!</p>
</tekno:AdminRole>
[/xml]

S60 Word Processors and Psion 5mx

I spent some time yesterday checking out which S60 word processor I’d like to use with my E71. I decided in the end that the answer would be, none.

One huge feature that is missing for me in every single one I tried, is styles. I find it really hard to outline a document without some kind of style library. Is it too much to ask to just have a choice of heading 1, 2, 3 and normal?

It’s a step backwards from my existing mobile word processing experience, the Psion 5mx.

Mind you a lot of stuff is a step backwards from the Psion. Okay yes it has some serious faults nowadays.

  • Very unclear screen
  • No easy mobile connectivity
  • No color
  • No decent web experience

But as a word processor for a mobile writer it does many things very well, some that still haven’t been matched.

  • Good keyboard for its size
  • Functional word processor
  • Excellent battery life

Of course correcting lots of the things it does badly would damage the excellent battery life. But still it would be nice if I could have a non-crippled word processor for my E71. Anyone know of one?

Dmitry Fedorov’s Airclick Plugin

Dmitry’s fantastic Multimedia Keyboard plug-in  for Griffin’s Airclick USB has been updated.

It gives you the ability to control any application that supports Multimedia Keyboards by simulating multimedia key or arrow key strokes. You don’t have to change to another plug-in to control different applications, in fact, you might never have to change it again.

Well now it even works with Adobe Flash players in full screen! (YouTube, Hulu, Amazon, JW FLV Player and similar)

You can download Dmitry’s plugin here:

http://www.dimin.net/software/airclick

WordPress Admin Dropdown Menu Plugin

I’ve been working a lot in the admin section of my WordPress install recently. Now my hosting doesn’t serve files to me very fast, particulaly admin pages. I installed google.gears and that sped things up some.

What’s really made a difference though is this drop down menu plugin for the admin pages. No more clicking through pages you didn’t need to get to the one you do.

Thanks to Ozh for that!

Stopping ASP.net concurrent logins

I’ve been working on a subscription site, logins are powered by the ASP.net membership provider system.

Now I want to stop people sharing their logins and avoiding paying for a subscription. We don’t really want multiple logins from the same username.

After a lot of Googling I came up with an almost suitable solution:

http://www.eggheadcafe.com/articles/20030418.asp

The only problem for me is that this solution stops a new login. This means that if a user logs in, closes the browser, and then logs in again, they are denied a login for the next twenty minutes (or however long the session timeout is set to).

So I switched things around, and actually ended up with a slightly simpler solution.

In my asp:Login control’s LoggedOn event I have the following:

protected void LoginMain_LoggedIn(object sender, EventArgs e)
{
    System.Web.UI.WebControls.Login senderLogin = sender as System.Web.UI.WebControls.Login;

    string key = senderLogin.UserName + senderLogin.Password;

    TimeSpan TimeOut = new TimeSpan(0, 0, HttpContext.Current.Session.Timeout, 0, 0);

    HttpContext.Current.Cache.Insert(key,
        Session.SessionID,
        null,
        DateTime.MaxValue,
        TimeOut,
        System.Web.Caching.CacheItemPriority.NotRemovable,
        null);

    Session["username"] = key;
}

We concatonate the username and password as before and use this as the key for a cache item. The cache item value though is set to the just logged in users SessionID. We then add the key to a session variable.

In global.asax we have:

protected void Application_PreRequestHandlerExecute(Object sender, EventArgs e)
{
    if (HttpContext.Current.Session != null)
    {
        if (Session["username"] != null)
        {
            string cacheKey = Session["username"].ToString();
            if ((string)HttpContext.Current.Cache[cacheKey] != Session.SessionID)
            {
                FormsAuthentication.SignOut();
                Session.Abandon();
                Response.Redirect("/errors/DuplicateLogin.aspx");
            }

            string user = (string)HttpContext.Current.Cache[cacheKey];
        }
    }
}

This will fire for every request. If the username session variable exists then the SessionID is taken from the cache and compared to the current SessionID. If they don’t match then the user is kicked to an error page after being logged out and Session.Abandoned.

This means that a second user logging in will change the cached SessionID and login fine, whilst the original user will be logged out.

The error message explains what has happened and provides support for what to do. Which is of course either, stop cheating me out of cash, or let us know if you think your account is compromised.

Accessing ASP.net masterpage properties from content page

If you use ASP.net masterpages then sooner or later you will have discovered that you cannot access your masterpage properties using Page.Master or simply Master.

Previously I have used the solution you see floating around a lot, that is to put the following in your content page aspx (assuming our masterpage is called Main.master):

<%@ MasterType VirtualPath="~/Main.master" %>

And the following in your code behind for example:

Master.BodyClass = "pgKeyboard";

It works fine, although for every new page you make you need to remember to add the MasterType declaration, which has always frustrated me.

So the other day I realised, obvious though it was once I had, that I could drop the MasterType declaration and simply cast the Master object to the correct type.

For example:

((Main)Master).BodyClass = “pgKeyboard”;

So if you can’t access your masterpage properties or methods, just remember you need to cast the Master object into your masterpage type.

Matched PB again!

I shot a 546 Portsmouth again yesterday night. That’s four in a row now. Shot six 7s, rather disappointing. Without them I’d have made the 550 Winter goal I set myself. Not much of the Winter season left now. Next chance is Monday evening, a little more concentration and we’ll get there.

WordPress Footer.php hacked

Well I’ve learned my lesson regarding critical security updates. I’ve been running a couple of version behind the latest for months now.

I then spotted a whole bunch of 404s in Google’s webmaster tools. Really odd links that shouldn’t even exist on my site. So after investigating I discovered that my footer.php was full of spam links.

So I deleted them. Next time I checked they had come back. So I exported my posts as XML and ditched both the WordPress and the database. I then reinstalled the lastest version of WordPress and imported my posts. Next time I will upgrade when a security patch is realeased!

The only remaining problem is the damage done to my search engine listings, I have fallen off the map completely. Googlebot still hasn’t revisted my site since I repaired the damage, so who knows how long before things correct themselves, I have made a resumbission request just in case I’ve been blacklisted or something.

DasBlog in a sub folder "SSE Provider did not find the database file"

If like me you run an installation of DasBlog in a sub folder/app then you may run into this error message when you start using ASP.net 2.0 membership/role providers in the base app.

The SSE Provider did not find the database file specified in the connection string. At the configured trust level (below High trust level), the SSE provider can not automatically create the database file.

All that is required to fix is to add:

<roleManager enabled=”false”/>

to system.web in the DasBlog web.config.