Archive for the ‘internet’ Category.

C# http authenticate

Sometimes URL requests are authenticated by the server your running against. For example if you want to update your Twitter status. Let’s take a look how we can do that easy.

using System.Net;
try
{
    string sURL = “http://twitter.com/statuses/update.xml?status=” + sText;
    // Create the web request
    HttpWebRequest request = WebRequest.Create(sURL) as HttpWebRequest;

    // Add authentication to request
    request.Credentials = new NetworkCredential(“myaccount”, “mypassword”);
    request.PreAuthenticate = true;
    request.Method = “POST”;

    // Get response
    using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
    {
        // Get the response stream
        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
        {
            // Console application output
            StringBuilder body = new StringBuilder(reader.ReadToEnd());
        }
    }
}
catch (Exception ex)
{
    Console.WriteLine(ex);
}

Boulder tech meetup, Dec 2nd

Went to the Boulder meetup yesterday, it was exciting as usual. With some nifty companies such as Me.dium now gone oneRiot search engine of current trends on the internet. The most interesting talk of the night was the new Yahoo BrowserPlus by Lloyd Hilaiel.

What is it ? “BrowserPlus™ is a technology for web browsers that allows developers to create rich web applications with desktop capabilities”
More development info here One impressive demo that Lloyd showed is motion censor driven. His laptop censors affected the code running in the browser. Pretty nice integration there. Check out the demos.

In hindsight, I should have snagged a T-shirt from him…

Cutting edge website

Three friends and I started a company in Iceland back in ’94.  We were pretty much fresh out of the University.  We did odd projects here and there as young companies go.

Then we came up with this brilliant idea, to make a website for the world championship in team handball.  That was to be held in Reykjavik in 1995.  There wasn’t much of dynamic web sites at the time, they sure existed not the norm though.  After striking a deal with the handball association the work begun.  The website even had an Oracle database on the back end for dynamic content.  Mostly to look up teams, players and game stats as the tournament took place.  Not only that it was also available both in Icelandic and English.

Like I said cutting edge in 1995, we even got published in the newspaper and Tv stations.  We had just started development when I had to move to New York to secure my green card.

Fantasy players market

We all know about the fantasy teams etc.  People have a lot of fun with it, how did your team do vs your friends.  Who is the last man standing at the end of the season.  If your into that, here is another new twist.  Virtual shares in sports players and there might be teams later.  For now it’s players in NBA, NHL, NFL etc.    OneSeason takes %1 commission of the trades, yes it’s real money, real stock market.  If your into it, head over to OneSeason and get $10 for signing up, enough to get you some shares of Micheal Jordan or any other player that already had an IPO.  IPO’s are issued once in a while, depending on market conditions.

Send email – C#

I had the need to email from C#, most of is obvious and straight forward. Still there are a couple of quirks. In case you need it here is a snippet.  Some ISP’s like comcast do not like it when you send email from your server over their network.  Therefor they block the default smtp port 25.  Most hosting places open up other smtp ports for you to use in that case, see the sample.

using System.Net.Mail;

    try
    {
        // Create a message and set up the recipient
        MailMessage message = new MailMessage(
        ”testme@mydomain.com”,
        ”someone@yahoo.com”,
        ”The subject”,
        ”The body of the email…..”);
         

        //  Add bcc
        message.Bcc.Add( new MailAddress( ”some@google.com) );
        // Setup the message.
        SmtpClient client = new SmtpClient(”mail.mydomain.com);
        // Default is port 25, set the one your isp doesn’t block
        client.Port = 1111;
        // set the email user / password for authentication
        client.Credentials = new System.Net.NetworkCredential(”testme@mydomain.com”, ”dontTell”);
         

        // Send it off
        client.Send(message);
    }
    catch (Exception ex)
    {
        Console.WriteLine(”Error sending email=” + ex.ToString() );
    }



Update – if you need to connect to the Google smtp server ( smtp.gmail.com ) then you need the following settings.

// the google send port
                client.Port = 587;
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                // set the email user / password for authentication
                client.Credentials = new System.Net.NetworkCredential(FROM_EMAIL, FROM_EMAIL_PASS);
                // Google uses secure socket layer for the connection
                client.EnableSsl = true;

Leet speak

Somehow I had L33t gone unnoticed, popular amongst gamers.  Although as most people in tech are aware using numbers to mask p@55w0rd5 can be helpful.  As usual Google is on top of things.