About Author: mike

Website
http://www.mkingscott.co.uk
Description
A nice guy, web developer using ASP.Net, martial arts fan and practitioner (when not crippled), film buff, husband and father :-)

Posts by mike

0

C# LINQ standards for Finding and Getting

A bit of a semantics thing here: recently I’ve been creating a lot of extension methods over using LINQ. I used to call my “search” operation GetByID, e.g.:

public Person GetByID(this List persons, personID)
{
    return persons.SingleOrDefault(p => p.PersonID == personID)
}

However, that then means I need to check for null after calling persons.GetByID(blah), which seems a bit odd for an explicit Get operation, as in “I’m sure this data is in here, if not, than an Exception would be permissible”.

So, now for extension method LINQ queries that use .SingleOrDefault I use FindByID to remind me to check for null afterwards, and my extension method GetByID now uses the LINQ .Single operator / thingy.

Very quick post, but there ya go :)

0

This is why I have a PS3

Awesome ad for the PS3, including many recognisable (and some not so recognisable) characters:

H/T to IGN PS3, natch

0

A message from the past for the present

Just watch this, and take on board what is being said.

Awesome – a h/t to Old Holborn for it

0

Pay Date Calculator – future work

As most of the traffic that arrives at this blog comes from the search term “pay date calculator”, it appears there’s a need for it.

I’ve never been that happy that a potential user has to install the .Net framework then the app, so I have decided to write the application for the Android OS, available on phones and tablets and sell it for a modest fee through Android Market.

I’ve not done Android development before, but the logic of the app remains the same, it’s just laying it out on screen that will be interesting, though I’m sure something else will come along to trip me up :)

Further updates will be posted; I’ve been Tweeting more than blogging so more blog posts should be forthcoming.

0

Awesome mini-trailer for Rise Of The Planet Of The Apes

This popped up on my Twitter timeline a while ago from First Showing, a great mini-trailer for Rise Of The Planet Of The Apes – what gamers would call a “sizzle reel”:

Pretty damn awesome, I’m looking forward to seeing this – after Captain America, Super 8, Immortals…

0

I got kicked in the head by Bill ‘Superfoot’ Wallace :-)

Yesterday, I went to a training seminar hosted by the martial arts legend Bill ‘Superfoot’ Wallace. If you are unaware of who he is, then you don’t know martial arts – but here’s his Wikipedia page. I’ve seen his stretching and fighting videos on YouTube, and remember watching him in a couple of late 70s / early 80s martial arts films, the latter being The Protector with Jackie Chan. He’s exceptionally flexible, with a hook kick that has been clocked at 60mph, which is pretty darn fast.

Without giving too much away – pay for your own seminar ;) – he took us through an EVIL stretch warm-up but gave a few pointers that I wasn’t aware of, and then told us to make our lead leg the “third hand”, and then we went into lots of kicking drills, but drills that involved our partner, making contact, not just techniques on the spot.

Bill’s teaching style is, er, unique :) Certainly not what I was expecting at all, very humorous and got his point across very well. He’d stop us every now and again to correct our technique, or to give further pointers. He also discussed tactics in sparring, and the point I’ll remember most about the day is that “it’s always my turn”, i.e. if you’re attacking and your opponent is blocking, he can’t attack you. Bill’s plan when he fights is to make the opponent move to block and create an opening elsewhere that he can exploit. Several “volunteers” were used to make this point, and all fell for what Bill wanted to happen, e.g. block a few low (on the belt) kicks, finally exposing their head, then Bill just kicks straight to the head, and it’s goodnight. It should be noted that Bill ‘knocked out’ 13 opponents with kicks to the body, really nowhere is safe ;)

For someone in his mid-60s (sorry, Bill) his flexibility is amazing, and his speed is incredible – but with it he has control. I can throw out a fairly decent height hook kick, but there’s not much control. When Bill was talking to me about I question I raised (going from a counter-fighter to a offensive fighter), he demonstrated how he’d make the change with working on the feints and speed, and before I knew it, bonk, he’d kicked me in the head. But it was just a tap, ridiculously light, but damn quick. Awesome.

At the end, there was a Q & A session (in which I asked my question just mentioned), but Bill also spoke about sparring with Joe Lewis, Tommy “The Hitman” Hearn and a boxer called Virgil Hill, all very interesting and entertaining. If you’ve seen Bill’s videos on YouTube, you’ll see that he favours his left leg – the reason for this is that when he started training in Karate (in Okinawa, obviously), he had his right knee in a cast from a high school wrestling injury, so the sensei said “start training, just use your left leg” and so he did and the rest is history.

What was really good was at the end of the seminar, he told us that we just learnt worked really well if you were Bill Wallace – we had to take what he had shown us and make it work for us, i.e. pick our favourite technique / feint, see what works for us, etc. Very good piece of advice as we are all different, physiologically and psychologically (e.g. I’m an arthritic cripple ;) )

It was a great seminar, highly enjoyable, learnt a lot and yes, I even got a signed photo of him – well, you would, wouldn’t you? A huge thank you to Dean Williams of the PKA for organising it :D

0

HTML5 or Silverlight – can’t I have you both?

At work recently, a kindly contractor gave us a demo of what can be achieved in Microsoft’s Silverlight. The layout XAML seemed simple enough, and the RIA Services made data-binding a snap, it was very impressive.

I have not followed Silverlight that closely, or indeed, at all. It has come on in leaps and bounds and with the advent of Silverlight 5 (debuted at Mix11 I think) adds even more enterprise-level functionality. It is something I will most definitely be investigating for Intranet development and gives me an answer to my recent ponderings of “what next?”.

Then I saw Mix11′s keynote on HTML5 in IE9 on Windows 7 – holy crap. The FourSquare 80s retro pixel application running natively in the browser (i.e. no plugins) was fantastic, as was the SVG anime that looked like video but was all real-time. I know that other browsers are HTML5 compliant (as much as they can be, it’s a developing spec), but cripes, it was impressive. In fact, if you have a HTML5 browser (IE9, Chrome, FireFox), get on over to The World’s Biggest Pac-Man site, where there are hundreds of inter-connected Pac-Man mazes to work through – as you exit the maze from the sides, you automatically go to the next maze.

Sure, it’s a game, sure it can be done on PC, games consoles, etc., but it’s running natively in a browser. HTML5 will open up a huge, rich experience on the internet and it’s also something I must investigate.

So, to sum up, 1 + 1 = 2. Ha. Seriously, I would look to Silverlight for intranet business applications where you can guarantee that the end user will have to install Silverlight, and HTML5 for “Joe Public” internet sites. Mind you, if Silverlight continues on its path, it may be shipped as part of the next Windows OS, or a Service Pack, or people will just come to see it as Flash-like, and just install it anyway.

Interesting times :)

Also, can’t I have you both? I’d buy that for a dollar!

0

Alan B’Stard on the Alternative Vote (AV)

With the sop to the Lib Dems for their partnership in the woeful coalition coming on the 5th May, we’ve seen lots of celebrities coming out to endorse the Yes camp – big deal. You know the Yes vote is in trouble when it asks celebrities for help, can’t their argument stand on its own? I assume they’re going for the people who recognise them from X Factor, Heat, Closer and the like, and hope they’ll be easily swayed (probably).

Although this has been known for a while, the Yes vote group has received a substantial amount of financial sponsorship / backing / bribe from the Electoral Reform Commission, who just so happen to be in charge of running elections in the UK. They also just so happen to make £millions if we move to an AV system; as usual Guido Fawkes has the story. It is a grubby little band, and if people vote for AV, more and more grubby coalitions will be formed for years, with the chance that there will never be an outright winner again.

There are two things you should know about AV:

  1. It is only used in three countries, and of those, two want to get rid of it
  2. Nick Clegg wants it

The second point is enough to convince me to vote No.

Anyhoo, here’s my good friend Alan B’Stard to explain why AV is a terrible, terrible idea:

Please note that you’ll need to watch it all the way through…

VOTE NO TO AV.

0

Rally Against Debt – site

Just a quick pointer that the Rally Against Debt blog is up:

Rally Against Debt

This is certainly a great cause – anything to show the State-addicted that the private sector is no longer willing to support them is A Good Thing :)

0

Rally Against Debt

Finally, a rally for normal, working people to protest in:

Rally Against Debt

Any visits to Fortnum and Mason’s by protestors will only be to marvel at their selection of quality goods and perhaps make the occasional purchase.

I think this is a great idea – it should not be hijacked by any left-wing anarchic idiots as the UK Uncut march on the 26th was. Mind you, the majority of the people in the march were just left-wing idiots, scared at seeing their State-supplied lifestyle being cut off. I firmly believe that more, deeper cuts will be required, preferably diversity co-ordinators instead of front-line services.

I work for a living, I have a private pension, will be losing Child Benefit in a couple of years, and can’t even get a required operation on the NHS despite barely using the NHS over the years. I require nothing from the State, and as such, the State should require nothing from me – it even takes taxes under threat of violence.

Perhaps this is what I should point the remainder of my life at – the shrinking / rolling back of the intrusive State…

0

A programming book? From me? Nah.

Being the wise, old, programming sage that I am (hahahahahaha!), I’ve built up a set of practices that I use in my development work. Such information has been gleaned from those old things with pages in, er, books, that’s it, and some from forums, and some from official guidelines and other official guidelines (it’s always good to have a choice of standards).

Anyway, I was thinking of collating them into a book, but then realised it would be more of a pamphlet, no-one would buy it, hard work and effort is meant to be free these days (thanks to the internet), etc.

I still might tho’, as I have a lot of real-world, pragmatic experience on how software development usually happens (badly in most places), and if you are able to introduce your own rules to your own work, it gives the illusion of control. It would be more of a tips book, with things like “Specs? Hahahaha!” and “Tab spacing is your friend”.

Well, it might help junior developers :P

Anyway, it’s more like a series of blog posts, so I’ll probably go with that, and then tweet the post URLs accordingly – stay tuned!

0

Two new trailers – Captain America and Your Highness

I saw these this evening, and thought they warranted inclusion. Plus, I’ve not blogged in ages, most of my vitriol goes out on Twitter these days ;)

First, a better-than-expected trailer for Captain America. It’s about a small, weedy man who gets turned down for the US Army in the Second World War and – wait, you really should know who Captain America is. Here’s the trailer:

Whaddya reckon? Looks pretty good, doesn’t it?

The second is a RED BAND TRAILER for Your Highness, starring James Franco and Danny McBride. I say RED BAND TRAILER as it has 18+ language in it, and bums and boobs, so be warned. It looks like a bit of a goofy laugh movie, so I’m in. Hey, not every film I watch has to be Inception, or The Seventh Seal, or Mon Oncle, or In The Realm Of The Senses, or Zatoichi, or Oldboy, or – ah, here’s the trailer:

<a href="http://video.msn.com/?mkt=us&#038;from=sp&#038;fg=shareEmbed&#038;vid=741da3f6-e99d-421b-b537-bdbf45a87a9c&#038;src=FLCP:sharebar:embed" target="_new" title="Exclusive: 'Your Highness' Trailer (Mature Audiences)">Video: Exclusive: &#8216;Your Highness&#8217; Trailer (Mature Audiences)</a>

“It’s a trap, a booby trap!” – worth the ticket price alone :)

0

A Year Of Self-Sufficiency – ta, Meryl Streep

So, last night Jacky and I watched Julie and Julia, a film about a modern-day lady (Julie Powell) attempting to cook all of Julia Child’s recipes in Mastering The Art Of French cooking. No mean feat, as Julie has 524 recipes to complete in 365 days. The film was highly entertaining, with great perfomances from Amy Adams, Meryl Streep and a favourite of mine, Stanley Tucci (a young Artie Buco?).

Anyhoo, Julie Powell blogged her progress – this was back in 2002 when all the cool kids were doing blogs, before everyone jumped on the blogging bandwagon (myself included) in order to write about what they love, as opposed to me who just needs to vent occasionally.

I’m glad to say my wife Jacky falls into the former category and, inspired by the film, has started blog with a year-long timeframe. As she is a keen gardener and wannabe smallholder, Jacky will be blogging about her attempt to become even more self-sufficient (we already grow and use quite a bit), but there’s still some lawn that hasn’t been dug up yet ;)

The blog can be found at A Year Of Self-Sufficiency, and I’ve dutifully included it in my blog roll. Her first post has been made this evening, stay tuned for more :)

0

Useful .Net LINQ, part 387 ;-)

Here’s another post to help me keep track of .Net stuff I find useful :)

This time, it’s how to get a string array of selected values (or text strings back from a ListBox via LINQ:

public string[] GetSelectedSearchFields() {
return uxFieldList.Items.Cast().Where(li => li.Selected).Select(li => li.Value).ToArray();
}

Obviously, uxFieldList is my ListBox, but it could be any List-supporting control, e.g. CheckBoxList, etc. If you want the text of the item instead of the value, simply change li => li.Value to li => li.Text. And I’m sure you can make more of the method than me, but I subscribe to the KISS approach ;)

0

Office-style buttons (accompanying images) with CSS

Image of what the rest of the post is about:

CSS Buttons

(Excuse the rest of the site / styling, it’s the ASP.Net default one)

Well, I’ve been meaning to write this post for a while, it’s another one of my “if I don’t write this down somewhere I’ll forget it” entries, of which I need to write a couple more, but they can wait.

Please note that this is for ASP.Net web development and CSS (Cascading Style Sheets), so if you’re expecting some funny clips, film trailers, a sad litany of my latest injuries, or Hungarian donkey porn, you’ll have to wait ;)

As part of a project I’m working on, a requirement was to have buttons with small images next to them, similar to the MS Office buttons, or like the links in IE’s Favorites bar that have the favicon next to them. I seem to recall that you couldn’t (easily) add an image to a button, so I kinda cheated and used an ASP.Net LinkButtons. These are hyperlinks that can also have server-side events. The styling of the button was what I was after, not the plain text, so I set the LinkButton to render as a button, and added the following style declaration (via the LinkButton’s CssClass property).

<asp:LinkButton runat="server" ID="uxPrevL" CausesValidation="false" CssClass="button back" Text="Prev" OnClick="uxPrevB_Click" Visible="false" Width="75px">

As you can see, I’m adding two style classes, button and back. Note that I’m also setting the width of the button, this can also be done via CSS, or with ASP.Net theming.

Here’s another button:

<asp:LinkButton runat="server" ID="uxNextL" CssClass="button next" Text="Next" OnClick="uxNextB_Click">

As you can see, the style classes for this button are button and next. Here’s the style definition for button

.button
{
background-color: #ddd;
background-position: 5% 50%;
background-repeat: no-repeat;
border: 2px outset #ddd;
cursor: pointer;
display: inline-block;
margin: 5px;
padding: 5px 5px 5px 25px;
text-align: center;
text-decoration: none;
}

As you can see, we’re setting a few background properties, a border, a handy (ha ha) cursor to illustrate the button is clickable, making the element display as inline-block, setting margins and border and padding, and some text alignment gubbins.

The important part here is the background-position property. Whatever background we place on the button will be position 5% of the width in from the left and 50% vertically, or, technically speaking, nudged in a bit and slapped in the middle. I was slapped in my middle one, I didn’t like it…

Ok, let’s get those images declared – remember we’ve got two style classes being applied, so here’s the necessary declarations:

.back
{
background-image: url('../Images/back.png');
}
.next
{
background-image: url('../Images/next.png');
}

And that’s basically it – you just declare the (appropriately sized) images you want to appear on the button and through the CSS magic of “applying several styles”, it works – honest ;)

I also changed the color of the button text when the mouse hovers over the button, and gave a faux “pressed in” appearance when they button was clicked via the following:

.button:hover
{
color: #000;
}
.button:active
{
border-style: inset;
}

The button was tested in IE7+ (forget you, IE6!) and FF3+, which were our target browsers, and should be ok on Mac browsers as well.

Let me know what you think, if you like :)

Tags: ,