• 28Jun
    Downloads Comments Off

    Love Komodo Edit and CodeIgniter? Yeah, me too. I created a CodeIgner snippet package which will greatly improve your productivity.

    Here you go!

    Enjoy!

    P.S. I’m sure I’ll be adding more snippets in the future so check back every once and awhile for updates.

    • Share/Save/Bookmark
  • 28Jun

    As root

    /usr/libexec/mysqld –skip-grant-tables –user=root

    mysql -u root
    UPDATE mysql.user SET Password=PASSWORD(’newpassword’) WHERE User=’root’;

    FLUSH PRIVILEGES;
    quit

    • Share/Save/Bookmark

    Tags: , ,

  • 14Jun

    The original version of the Doctrine for CodeIgniter 1.0 plugin by Nicholas Husher is set up so the generated models don’t go into the models directory of the application directory used by CodeIgniter.

    So I decided to modify it a bit so the generated models go into and can be accessed from the system/application/models/ directory. I’ve also created a controller which, when called, will generate the data model ORM classes for you.

    A big thank you goes out to both Nicholas and the Doctrine team for making a great ORM for use with CodeIgniter.

    Download it here.

    • Share/Save/Bookmark

    Tags: , , , , ,

  • 03Jun

    If you are using Google Apps Gmail for your domain name’s email. Then you will want to drag the link  below inspired by GmailThis! below to your bookmarks bar. Then go to your browser’s bookmark management dialog window and open the properties for this bookmark to replace MYDOMAINNAME with the domain name that you are using Google Apps Gmail for in the URL field. Now you will be able to send a link with the page’s title as the subject and the URL link as the body for any page you are currently on. It will open a small window which is ready for you to add recipients and click send. So now you have the same functionality you would get from using your browser’s method for desktop email clients.

    GoogleAppThis!

    • Share/Save/Bookmark

    Tags: , , ,

  • 25May

    This is a simple BlogEngine.NET control which can be used in a custom page within a BlogEngine.NET site to display posts from a certain category for use in a custom landing page or the likes. It can be easily modified to show posts from all categories too.

    Download it here.

    • Share/Save/Bookmark
  • 25May

    As many of you know MySQL lacked such basic functionality for way too long. Sadly this also means that many developers using it don’t use them when appropriate since they have gone without them for so long and now most applications today are written using ORM which can negate the needs for such things.

    However there are situations where stored procedures are beneficial and when they are not. Being a database and object oriented developer I can see why people in either camp has their own preference. Regardless, let me outlines the pros and cons so you may decide for yourself if they may be of use along with a simple example of one so you know how to create and use them if needed. Since they are rather simple I won’t get too extensive with it.

    Pros:

    • Performance
      • Since they are pre-compiled statements you lose the overhead of compiling the statement when calling one.
    • Centralized
      • If you need to make a quick change to the SQL that doesn’t affect the rows it outputs such as adding an additional where clause you just alter the stored procedure without the need to deploy the application
    • Transactional
      • Even though some frameworks allow ORM calls to be transactional and not all storage engines allow for it it can still be a powerful tool in regards to the need to have a all succeed or all fail scenario
    • ORM Functions
      • Even if you are using an ORM they can still be used as most ORM frameworks allow you to make calls to them in the form of a function native to the language you are using.

    Cons:

    • Tightly Coupled
      • In the world of object oriented and Agile development they make things too tightly coupled for proper OO and TDD practices to be used.
    • Testing
      • There is not much in the way of debugging SQL in the way you would a normal programming language.
    • Versioning
      • There are methods to perform versioning however they are highly sub-par compared to normal code in an SCM.
    • SQL Makes for a Lousy Language
      • When it comes to simply retrieve data it is perfect however when you go beyond that and in stored procedures you usually do it is sad in comparison to a regular language.
    • Domain Logic Tends To End Up Inside Them
      • This is pretty self explanatory

    Sample Stored Procedure:

    CREATE PROCEDURE spGetLogin(username VARCHAR(50), password VARCHAR(50))
    BEGIN

    DECLARE success INT;

    IF SELECT COUNT(*) FROM Users u WHERE u.username = username AND u.password = password > 0 THEN

    SET success = 1;

    ELSE

    SET success = 0;

    END IF;

    SELECT success;

    END

    There is also triggers which react to commands on a table however even though they may seem useful I find them to be evil in my experience. I mean lets say you want to log activity using one so for every SELECT, UPDATE, or INSERT you will have a second INSERT’s overhead. You can also create functions however I have never seen much use for them as most of the reasons you would want to use them are already covered by stored procedures. That is not to say triggers and functions are useless. There are the rare occasion they can prove to be useful.

    So as you can see they have some pretty good benefits and some awful downsides. However sometimes they are the best tool for the job and now you know how to decide if that is the case.

    Feel free to add any critisism, comments or quetions!

    • Share/Save/Bookmark

    Tags: , , , ,

  • 23May

    People keep saying how Chrome doesn’t have extensions even though it has since days 1, Google Gears. Go to your gMail account or even your WordPress’s admin. Of course they are working on an official extensions framework but give them some credit, Google Gears can do some things FF plugins can’t and of course the opposite is true. Check out http://code.google.com/events/io/sessions.html for more info.

    • Share/Save/Bookmark

    Tags: , , ,

  • 28Apr

    RESTful communication is a great method for light weight communication across systems not requiring the complexity or standards based interoperability of web services. I have used these methods for years with multiple vendors and clients for various CRM related tasks and it worked great. Of course the system supported web services however the need to use them was rare in comparison.

    Now it is no longer something used just for B2B based communication but also for standard everyday services such as Twitter. So I will use their REST based API to demonstrate how to read, write and authenticate using REST.

    Below is a simple read in order to retrieve the friends timeline for the authenticated user.

    1.  
    2. public static string GetTimeline(string username, string password)
    3. {
    4.     //take the Twitter credentials and Base64 encode them
    5.  
    6.     string encoded_user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
    7.     //create a web request instance for the friends timeline in XML format      
    8.  
    9.     HttpWebRequest tweet_request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/friends_timeline.xml");
    10.  
    11.     //add the encoded creadentials to the requests header
    12.  
    13.     tweet_request.Headers.Add("Authorization", "Basic " + encoded_user);
    14.     //since we are performing a read the method is set to GET
    15.  
    16.     tweet_request.Method = "GET";
    17.     //the call is made and we create an instance of the response’s stream
    18.  
    19.     Stream response_stream = tweet_request.GetResponse().GetResponseStream();
    20.     //now we simply convert the XML response into a string that can be
    21.  
    22.     //loaded into an XML document and access the data via XPath
    23.  
    24.     StringBuilder response_builder = new StringBuilder();
    25.     int i = 0;
    26.     byte[] response_buffer = new byte[8192];
    27.     do
    28.     {
    29.         i = response_stream.Read(response_buffer, 0, response_buffer.Length);
    30.         if (i != 0)
    31.         {
    32.             response_builder.Append(Encoding.ASCII.GetString(response_buffer, 0, i));
    33.         }
    34.     }
    35.     while (i > 0);
    36.     response_stream.Close();
    37.     return response_builder.ToString();
    38. }
    39.  

    Here we will now write to the service by updating the twitter user’s current status.

    1.  
    2. public static void Send(string username, string password, string status)
    3. {
    4.     //convert data to be written to a byte array
    5.  
    6.     byte[] tweet_bytes = System.Text.Encoding.ASCII.GetBytes("status=" + status);
    7.     //Base64 encode the credentials
    8.  
    9.     string encoded_user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
    10.     //create a web request instance for the status update in XML format
    11.  
    12.     HttpWebRequest tweet_request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
    13.  
    14.     //certain web servers have trouble with HTTP requests using Expect-100
    15.  
    16.     tweet_request.ServicePoint.Expect100Continue = false;
    17.     //add the encoded credentials to the request header
    18.  
    19.     tweet_request.Headers.Add("Authorization", "Basic " + encoded_user);
    20.     //since we are writing we now set the method to POST, the size of data to
    21.  
    22.     //be written and the mime type accordingly
    23.  
    24.     tweet_request.Method = "POST";
    25.     tweet_request.ContentType = "application/x-www-form-urlencoded";
    26.     tweet_request.ContentLength = tweet_bytes.Length;
    27.     //create stream instance from request
    28.  
    29.     Stream request_stream = tweet_request.GetRequestStream();
    30.     //finally we write the update to the stream
    31.  
    32.     request_stream.Write(tweet_bytes, 0, tweet_bytes.Length);
    33.     request_stream.Close();
    34. }
    35.  

    So as you can see REST calls are the easy part of handling RESTful communication. It is nothing more than standard HTTP calls. It is what you do to and with the data that is the hard part. So now you can see why it is so simple and light weight. Of course I could go into detail describing REST however it is outside the scope of this article and the code pretty much says it all. Enjoy!

    • Share/Save/Bookmark

    Tags: , , ,

  • 18Apr

    Most tech savvy users hate to have unecessary Windows services running since they take up RAM and CPU cycles and doing nothing for you in return. So, lets take this preference a step further.

     

    As a Microsoft based (.NET/SQL Server) developer we usually need SQL Server running on our boxes for testing purposes. Some of us, like myself, has to install the full version and not just the express version. Since we only need it at times like those and being a rather hefty service(s) I like to shut them down it down when I am not using it. It is a rather simple process to make this work. 

     

    First you'll need to run the services.msc command. When the service console pops scroll down the the SQL Server service, right click it and choose properties. First thing you'll want to do is to set the drop down to manual. Then you'll want to copy the value for service name. Finally hit the stop button and click ok.

     

    Now fire up Management Studio and hit cancel on the login dialog if you haven't already changed this setting. The click on the options menu, choose external tools and follow the steps below.

     

    1. In the name field enter "Start Server" 
    2. In the command field enter c:windowssystem32sc.exe
    3. In the arguments field type start
    4. In the same field hit space and paste in the service name you copied earlier
    5. Then click add and repeat steps 1-4 except use the word stop where it says start
    6. Click OK
    7. Now go to the tools menu and choose options
    8. In the drop select open empty environment
     
     
    You can do the same with SSAS and the likes if they are installed. So now when you open Management Studio it no longer prompts you to connect to a server in order to give you a chance hit the tools menu and click start server. When you are done just go back to the tools menu and hit stop server so you can go about your other duties without SQL Server chewing away at your precious resources.
     
    You can also make the work for remote servers (in your LAN that is) by adding \servername directly after sc.exe. Also the object explorer pane has the connect/disconnect buttons in the event that you only connect upon starting Management Studio.
     
    That and if anything else, we are making the world slightly (ok, very slightly) greener since most of us cannot power down our work stations since we need to remote into them in the event of an emergency or the likes after hours.
     
    AAlso, you can limit the memory SQL server uses on your machine by right clicking the server in object explorer, choosing properties, going to the memory section and enter a suitable amount of megabytes. For most of the applications in development you can get away with 64MB-128MB for development purposes. While I'm on the subject it is best to have your production servers run with about 1GB-2GB less than what is installed to leave room for the OS. If left untouched it can bring the server to its knees. Although, hopefully you are fortunate enough to have a DBA on your team who will already know and have done this. 

     

    • Share/Save/Bookmark

    Tags: , ,

  • 13Apr

    A little while ago I was speaking with technical writer, Jon Arking, about test driven development which led me to a conclusion that I believe will be a benefit to anyone reading this. The topic was my experience with test driven development. However it also led into my thoughts on the subject as well.

    I do agree with many aspects of the overall Agile methodology. However I definitely agree with all of them. One example would definitely have to be paired programming. I do see the advantages of it however as any software engineer knows, there is a point in our day while developing where we get into a "zone" where we are totally immersed in our development effort and the ideas just keep flowing. I don't see this happening with paired programming. But anyway, let me get to the point of this article, test driven development.

    There are 3 sides I see developers fall into involving unit testing. There is the stadard unit testers, those who do not use unit testing and the test driven developers. Many from the 2 sides not a part of test driven development have made many arguments against it. They believe it is slows down development or that there is no point in testing anything that hasn't even been written yet. Well I hope the perspective and analogy helps them to understand test driven development.

    In many sciences, a scientist comes up with a prototype. With that prototype they perform the many tests and modifcations needed before producing anything production worthy. Even in the development of the prototype they performed various tests to get to the point where they have a prototype worthy enough of using it to help them advance it to the level where it can be of use to the general public.

    In computer science, this would be considered test driven development. These scientists don't come up with an idea and go right to building/creating something meant for use by the general public and perform testing on these production models while producing them. The production/general public release of their innovation was created without the requirement of testing because it has already been through thorough test during and after the development of the prototype. At that point everything has been thoroughly tested and calculated that there is no need for any such testing in the development of a production/general public release.

    I see no reason why computer science should be any different and as I have just stated, this is where test driven development becomes the perfect fit for us to follow the same methods of other science related fields. We come up with an idea and throughout each step of flushing out that idea we test it to make sure we are on the right track. Then after all the ideas are flushed out and tested we have our prototype upon which we can then perform more comprehensive testing.

    Once all of this has been completed we can then, very quickly, produce a production worthy application or subset of an application. Everything is layed out in detail and thoroughly tested. This allows us to be completely confident in the final product. Also, we have the benefit of the Agile aspects this brings us for any future changes such as all the tests we already have in place to be reused to ensure any changes that do come along are released with the same quality as the original release.

    I don't think it is either faster or slower than other methods. However there are aspects I am sure of, it will provide rock solid software and just makes sense when looking at it from this perspective. 

    • Share/Save/Bookmark

    Tags: , ,

« Previous Entries