ASP.NET Cross Page Postsacks

And when to use what method: http://odetocode.com/articles/421.aspx

 Sometimes I forget things I havent used in a while....

 Also an interesting article on the Big Ball Of Mud design pattern.

Currently rated 1.0 by 2 people

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

Posted by: Chris
Posted on: 4/18/2011 at 5:10 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Looking for a flatmate!

Looking for a new flatmate (my current one is moving back home to Bermuda - lucky!) for this beautiful docklands flat.  2 minute walk to East India DLR, 15 to Canary Warf, 5 to the Thames (beat the tube strikes on the river!)

Perfect Condition (the whole building is only a couple of years old) Double room, lots of storage space, seperate bathrooms, large living room, leather sofas, fully equipped kitchen.  Comes with free Gym on the 1st floor, Concierge, secure area for storing bicycles, Balcony and the guy living there isn't too bad either (bit of a geek though) (that's me btw)

The rent is 780 pounds a month and includes Council tax and Electricity.  Plus, the tower is one of those 'eco-friendly' ones which pretty much never gets cold (it's toasty warm all year round...not too hot, not too cold...imagine a warm hug, that's it. (Note: actual warm hugs not included))

Me?  I'm a geek (This site runs on my own VPC and everything) who is into Rock and Jazz but is quietly sociable (I wont be playing thrash metal out my room at 3am - but do enjoy going to rock pubs - or chilling listening to smooth jazz in Camden.)

 

Interested?  Clicky the 'Contact' linky above!

 

Pics:

http://www.ninja-monkey.co.uk/byte/flat/lounge.jpg

http://www.ninja-monkey.co.uk/byte/flat/balcony.jpg

http://www.ninja-monkey.co.uk/byte/flat/kitchen.jpg

Currently rated 3.0 by 2 people

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

Posted by: Chris
Posted on: 1/6/2011 at 4:39 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Octopus Badass

You want badass?


The female Blanket Octopus does not squirt ink when she is threatened, instead, she releases a large blanket around herself to make herself look bigger.....Oh yeah, and she rips off the arms of the Portuguese man o' war and beat the living hell out of you with it.  Think about that, she rips poison death off of a jellyfish, AND BEATS YOU WITH IT.


She is so badass, the male of the species is only a few centimeters long, and when mating, rips one of his arms off, filled with sperm, gives it to her and then dies.  She is so badass, the male RIPS HIS ARM OFF AND DIES just to get it over with.


I think I just discovered something harder than Clegg Norris.

Currently rated 3.0 by 2 people

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

Posted by: Chris
Posted on: 11/17/2010 at 11:47 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Comments

For the time being I've killed comments - I'm sick of advertising VX on my blog from all the blog spam :D (PS, blogspammers - you all bastards and I hope you DIAF.)

Currently rated 2.3 by 3 people

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

Posted by: root
Posted on: 10/18/2010 at 11:34 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Desktop Win

In embedding an easter egg into an app at work, I found possibly the coolest wallpaper which I have added to the rotation.  Whatcha think?

Currently rated 1.0 by 2 people

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

Posted by: Chris
Posted on: 8/29/2010 at 3:40 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (7) | Post RSSRSS comment feed

Why upgrade code to .NET 4?

They only went and added a TryParse to the Guid Object!  HOLY BALLS!

 

About time.

Currently rated 1.0 by 1 people

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

Posted by: Chris
Posted on: 8/24/2010 at 11:44 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (11) | Post RSSRSS comment feed

New Host

Due to a series of downtime and loooong delays fixing them, I'm bailing off of my current host and moving back to the wonderfull 1and1 - Just installing the features needed to run my sites the server is feeling much more snappy and responsive - lets hope its a good move!

If you can see this post, then your using the new updated DNS settings and are browsing NinjaMonkey on the new and improved Mamba!

Be the first to rate this post

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

Posted by: Chris
Posted on: 6/14/2010 at 8:00 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (17) | Post RSSRSS comment feed

CleggWorship

Currently rated 1.0 by 3 people

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

Posted by: Chris
Posted on: 4/26/2010 at 5:14 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (13) | Post RSSRSS comment feed

Here's to blogs!

Currently I am eating a biscuit in honor of Blogs, a brand new one in specific, and how wonderful they are.

 

Here's to blogs.

Currently rated 5.0 by 1 people

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

Posted by: Chris
Posted on: 4/16/2010 at 11:17 AM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (40) | Post RSSRSS comment feed

Talking to Spotify

The Mission: Give the blue ThinkVantage button on my Thinkpad something usful to do

The Solution:  Make it pause Spotify

The Implementation:

This one comes in two parts, first of all we need to look at what makes the Blue ThinkVantage button tick.  Now, personally I dont get the point of that ThinkVantage menu dealio that comes up when you hit the blue button, so when I installed Windows 7 it wasnt something that got re-installed.  However, to get the button funcational at all you need to install the HotKey Manager (avaliable on the Lenovo site, I dont have a link im afraid as I've had it installed forever to get the volume keys working.  If you volume keys work, your all set, if they dont, you have to go find a driver before you continue I'm afraid) and then fire up The Registry.

 

Aww hell, I've always wanted to say this.

 

Warning: Playing with your registry can severly screw up your computer, children, life and any family pets.  Registry hacking is the start of a long slippery slope down to Heroin addiction and prostitution.  Or....some kind of disclaimer like that, basically - don't mess around in the registry, you'll probally brick your computer unless you know what you are doing.

 

So, we have totally ignored that warning and gone start/run/regedit and then navigated to HKLM/Software/IBM/TPHOTKEY.  Now, you may, or may not have the following key, so if you don't have it, create it - you want to go into the 8001 key, which apparently is the blue button.  Then you add a string value called "File" and give it the path to the program you want to fire off of the buton, so if you put "C:\\windows\\notepad.exe" (and it's a good idea to do that once to make sure it's working ok) when you hit the blue button, notepad will fire up.  Note the double backslashes in the path, and remember to use the old ~1 DOS style folder naming, so C:\Program Files beecomes C:\\Progra~1\\.

http://forum.notebookreview.com/showthread.php?s=409a0bf7627cccc6ee612fc3efe18838&t=171644

Ok, thats part one.  Now on to part B!

You need to write some code here, basically what we are after is a form which loads, finds and then fires a message to spotify telling it to play/pause, and then closes again. The following will work (sorry, its late I ant be bothered to code format this one):

 using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace PlayPause
{
    public partial class Form1 : Form
    {
        private const int APPCOMMAND_PLAY_PAUSE = 14;
        private const int WM_APPCOMMAND = 0x0319;
        private System.Int32 iHandle;


        [DllImport("user32.dll")]
        public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

        [DllImport("User32.dll")]
        public static extern int FindWindow(string strClassName,
                                                 string strWindowName);

        [DllImport("User32.dll")]
        public static extern Int32 SendMessage(
            int hWnd,               // handle to destination window
            int Msg,                // message
            int wParam,             // first message parameter
            int lParam);            // second message parameter


        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                iHandle = FindWindow("SpotifyMainWindow", null);
                int vCallReturn = SendMessage(iHandle, WM_APPCOMMAND, 0x00000000, APPCOMMAND_PLAY_PAUSE << 16);
                this.Close();
            }
            catch (Exception)
            {
                this.Close();
            }
        }
    }
}

What your doing is pulling in the methods you need from the Windows API, setting up your constants into integers, then on load you are using FindWindow and the Spotify main windows Class (you set the last parameter to blank because Spotify keeps changing it's title so you cant rely on that to identify the window) to get the window handle of Spotify, then sending the window a message of class WM_APPCOMMAND (The media keys commands) and the command itself, APPCOMMAND_PLAY_PAUSE (which we bitshift 16 places).  We then close the window.  I also have it set up to load minimised and not appear on the taskbar, so it dosnt look like a window has loaded at all.

You then tie the two steps toegether by pointing your registry key at the exe you just made  and wam, the Blue Button is pausing Spotify!

Here are the links I used to figure the above out - I really dont get the oppotunity to play with Native code much, being a web developer, so it was a fun explore of the Interop Services.

http://msdn.microsoft.com/en-us/library/ms646275%28VS.85%29.aspx

http://www.codeproject.com/KB/cs/wmp_pinvoke.aspx?msg=735041

http://www.microsoft.com/indonesia/msdn/pinvoke.aspx

http://www.codeproject.com/KB/wtl/WTLAppButtons.aspx?msg=2332697

http://kalshagar.wikispaces.com/Remote+controlling+Windows+media+player+in+C

Currently rated 5.0 by 1 people

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

Posted by: Chris
Posted on: 4/14/2010 at 5:21 PM
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (66) | Post RSSRSS comment feed