Tech's Next Global Challenge

We can choose to ignore this change or embrace it. We as an industry can live or die by it. Let the games begin!
Read: Tech's Next Global Challenge
Labels: Coding, Industry News

Labels: Coding, Industry News


"The file you are trying to open, '[filename]', is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now?"After searching for hours, I finally ran into this document from MS that essentially says this is a "feature" of the new Excel and no matter how much everyone hates it, they won't fix it. Here's an excerpt from that document:
(Yes | No | Help)
"The current design does not allow you to open HTML content from a web site in Excel... So ASP pages that return HTML and set the MIME type to something like XLS to try to force the HTML to open in Excel instead of the web browser (as expected) will always get the security alert... If you use an HTML MIME type, then the web browser will open the content instead of Excel. So there is no good workaround for this case because of the lack of a special MIME type for HTML/MHTML that is Excel specific. You can add your own MIME type if you control both the web server and the client desktops that need access to it, but otherwise the best option is to use a different file format or alert your users of the warning and tell them to select Yes to the dialog." [Emphasis added]In other words, give up because there's no good solution. Here's some bad solutions you could try, though:
![]() | Padded Lamposts Cause Fuss in London - For GPS using people who never look up from their cell. May Day Boycott Looming, EBay Revises Impact of 'Bug' - DO NOT USE EBAY ON MAY 1ST! British Security Camera Can See Through Clothes - Brits rights are quickly disapearring. 1.15: Code Security - This is how crappy code started. How to save money running a startup (17 really good tips) - Good tips for any business really. Bloxes Cardboard Modular Building Blocks - These would be awesome to use in a loft. Gmail Assistant: Keep Tabs on Your Gmail Accounts - Does what it says. Porcupine Flashlight Weaponized For Your Pleasure - Blind and mame your foes. Elgan: Making the phone-PC connection - We all want a cell that works seamlessly with our PC. Savvy Circle Monitors Your Wishlist for Price Drops - Yet another way to get the best price. Review: Ultimate Ears iPhone Earbuds Let You Talk Pretty, Today - Because earbuds suck. |
Labels: Apple, Audio, Coding, Google, Mobile, Neat Stuff
In Part 2 we discussed how to add an installer for the Windows Service we wrote in Part 1. Today, we'll learn how we can tell the Installer to start our service after it has been installed.
This article is one in a five-part series covering the following topics:
using System.ServiceProcess;using System;3. Start your Service using the ServiceController.
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration.Install;
using System.ServiceProcess;
namespace SuperService
{
[RunInstaller(true)]
public partial class ProjectInstaller : Installer
{
public ProjectInstaller()
{
InitializeComponent();
}public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
}
}
public override void Install(System.Collections.IDictionary stateSaver)Let's break this down for ya'. As I mentioned before, we add our code to start our service after the base.Install line.
{
base.Install(stateSaver);
ServiceController controller = new ServiceController("Logger");
controller.Start();
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
ServiceController controller = new ServiceController("Logger");
try
{
controller.Start();
}
catch (Exception ex)
{
String source = "SuperService Installer";
String log = "Application";
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, log);
}
EventLog eLog = new EventLog();
eLog.Source = source;
eLog.WriteEntry(@"The service could not be started. Please start the service manually. Error: " + ex.Message, EventLogEntryType.Error);
}
}
Labels: Coding
Recently I was working on a project in .NET 1.1 and had to use a DataGrid. It had been a while since I used the old thing. (Anymore I use mostly third-party grids.) I was adding an EditCommandColumn to it, to allow the user to edit any of the rows. For some reason, I'd hit the Edit button and none of the editable columns would turn into textboxes.
I had to kick myself since I knew I had experienced this same issue before and since it's such a novice issue, but I couldn't remember how to fix it! It finally dawned on me (it was really a stupid thing) so I figured I'd post about it for anyone else out there kicking themselves for being stuck on the same problem.
In the subroutine you have your DataGrid's EditCommand event bound to, you need to set the grid's EditItemIndex to e.Item.ItemIndex, and rebind the contol! Example:
private void Page_Load(object sender, System.EventArgs e)
{
dgDealers.EditCommand += new DataGridCommandEventHandler(dgDealers_EditCommand);
if(!this.IsPostBack)
{
LoadGridData();
}
}
private void LoadGridData()
{
// Get the data from the database.
SqlConnection conn = db.NewOpenConn();
SqlDataAdapter da = new SqlDataAdapter("EXECUTE SelectDealers",conn);
DataTable dt = new DataTable("dealers");
//Fill it into the DataGrid.
da.Fill(dt);
dgDealers.DataSource = dt;
dgDealers.DataBind();
ViewState["gridData"] = dt;
//Cleanup.
conn.Close();
da.Dispose();
conn.Dispose();
}
private void RebindGrid()
{
//Set the DataSource to the DataTable previously saved in the ViewState
dgDealers.DataSource = ViewState["gridData"];
dgDealers.DataBind();
}
private void dgDealers_EditCommand(object source, DataGridCommandEventArgs e)
{
dgDealers.EditItemIndex = e.Item.ItemIndex;
RebindGrid();
}
Labels: Coding
Today I was working on some inherited code and found myself wondering what a particular database field meant. I tried searching the application's code, but being a good little programmer the previous developer had used stored procedures for all the database calls. So off I went to internetland to find how to find a stored procedure containing specific text. Here's what I found:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%myField%'
AND ROUTINE_TYPE='PROCEDURE'
In Part 1 we discussed how to write a simple Windows Service that used a timer to write to to the Event Log every 5 minutes. Although we can use installutil to manually add the service to Server Explorer, this can be cumbersome when deploying our application. This is especially true when we need to deploy to multiple machines or the Windows Service is being deployed directly by our customer. To simplify this process, we'll learn how to add an installer for our solution and tell that installer to add the service for us.
This article is one in a five-part series covering the following topics:








Labels: Coding
Not a lot going on today in the Blogosphere.
Today's Daily Links go out in memory of those great minds lost in the Challenger disaster on this day in 1986.
Labels: Apple, Coding, Mobile, Robotics, Space, Windows
Part of a project I recently completed involved developing a custom email queue Windows Service in C# on the .NET 2.0 Framework. The application itself was quite simple. Unfortunately it had been some time since I wrote a Windows Service, and I hadn't written one on the 2.0 Framework and couldn't really remember much about it from the 1.1 days.
To the internet I went. I found lots of helpful articles on how to write the service, but not so many on how to start it after install, how to debug it, or how to add it to the uninstaller. However with a little imaginative searching and guesswork I managed to overcome. It sure would have helped me to have all of these topics in one place, so I figured I'd do a collection of articles for anyone out there struggling with the same issues.
This article is the first in a five-part series covering the following topics:



ServicesToRun = new ServiceBase[] { new Service1() };

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
namespace SuperService
{
partial class Logger : ServiceBase
{
public Logger()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
// TODO: Add code here to start your service.
}
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
}
}
}
Logging to the Event Log is a bit out of the scope of this article, but I do want to point out one line:
static void LogEvent(String Message, EventLogEntryType type)
{
String source = "Logger";
String log = "Application";
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, log);
}
EventLog eLog = new EventLog();
eLog.Source = source;
eLog.WriteEntry(Message, type);
}
String source = "Logger";This string specifies what you want displayed for the Source column in the Event Log.Now we'll have entries added to the Event Log when the service starts and stops, but what about our timer?
protected override void OnStart(string[] args)
{
LogEvent("This SuperService has started!", EventLogEntryType.Information);
}
protected override void OnStop()
{
LogEvent("This SuperService has stopped.", EventLogEntryType.Information);
}
namespace SuperService
{
partial class Logger : ServiceBase
{
public Logger()
{
InitializeComponent();
}
void timer1_Tick(object sender, EventArgs e)
{
LogEvent("This Timer has been ticked!", EventLogEntryType.Information);
}
protected override void OnStart(string[] args)
{
timer1.Tick += new EventHandler(timer1_Tick);
timer1.Start();
LogEvent("This SuperService has started!", EventLogEntryType.Information);
}
protected override void OnStop()
{
LogEvent("This SuperService has stopped.", EventLogEntryType.Information);
}
protected override void OnPause()
{
base.OnPause();
timer1.Stop();
}
protected override void OnContinue()
{
base.OnContinue();
timer1.Start();
}
static void LogEvent(String Message, EventLogEntryType type)
{
String source = "Logger";
String log = "Application";
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, log);
}
EventLog eLog = new EventLog();
eLog.Source = source;
eLog.WriteEntry(Message, type);
}
}
}
Labels: Coding
This awesome article's site went down when it hit the front page of Digg. Here's the original link. Be sure and check it out if it's back up, and Digg it.
Today we are presenting a round-up of 101 CSS techniques designers use all the time. Definitely worth taking a very close look at! This is just the first series , the second part will be coming soon, stay tuned and Enjoy!
Update:
You can check Part2 here.
CSS sprites save HTTP requests by using CSS positioning to selectively display composite background images. To maximize accessibility and usability, CSS sprites are best used for icons or decorative effects.
Rounded corners is one of the most popular and frequently requested CSS techniques. There lots of ways to create rounded corners with CSS, but they always require lots of complex HTML and CSS. Here are easy ways to achieve this effect.

Thierry Image Placement: Image Placement vs. Image Replacement (FIR)
This technique is mostly for headlines by using CSS to replace normal HTML text, with a background image in order to achieve a particular look.Several different image replacement methods have been proposed, each with their pros and cons.
when you need image replacement you can check the Gilder/Levin Method as described by Dave Shea or, if the replaced text is linked and CSS support for IE/Mac is required, the Gilder Levin Ryznar Jacoubsen IR method.
Sliding Doors of CSS introduced a new technique for creating visually stunning interface elements with simple, text-based, semantic markup.Beautifully crafted, truly flexible interface components which expand and contract with the size of the text can be created if we use two separate background images.
Sliding Doors" Box– Rounded Corners for All- The goal of this technique was to create rounded-corner boxes with visual flare and the absolute minimal amount of semantically correct markup. While making sure they could resize while keeping their backgrounds intact.
How many times do you have an image floated left in a block of content, but want to keep that content from wrapping around your image?
This technique allows you to wrap around image text flow control to emulate magazine style page layouts.
One of the somewhat frustrating properties of CSS is the fact that elements only stretch vertically as far as they need to. So how can we make all columns appear to be the same height? Several techniques was introduced to solve this issue.
Here is the CSS used to make this structure behave like a table:
.equal { display:table; } .row { display:table-row; } .row div { display:table-cell; } Why use a list? Because a navigation bar, or menu, is a list of links. The most semantic way of marking up a list of links is to use a list element. Using a list also has the benefit of providing structure even if CSS is disabled.


Headers in Web pages–marked up with h1, h2, h3, h4, h5, or h6 elements–help the reader determine the purpose of sections in content. If your header is visually stimulating, the odds are better that the section will capture your reader’s eye.
A technique to build flexible CSS drop shadows that can be applied to arbitrary block elements that can expand as the content of the block changes shape.
One of the trickiest things to control, in a CSS-driven design, is the transparency of the interaction between foreground and background content.Below is a list of the best examples of the differing transparency approaches possible with CSS.
A new standard from the W3C promises to allow web servers to talk to each other super-fast.
When it comes to bandwidth usage, binary beats text any day. The same is true when it comes to CPU processing of data. That's why programs are compiled and why most databases don't simply store data in giant text files. So, it doesn't make much sense for XML, a metalanguage who's primary purpose is the interchange of data on the Web, to take the form of plain text.
To address this issue the W3C has recently been developing a standard called EXI (Efficient XML Interchange) that represents XML data in a binary form. This should mark a significant improvement over both data compression and commercial XML hardware-accelerators available on the market today. "It is unlike data compression, which has overhead associated with it", explained John Schneider, co-editor of the EXI working draft, "There are people out there that are buying XML accelerators and hardware to speed up XML processing... but it doesn't do anything for bandwidth."
Representing XML as binary will help solve both issues because it will not only be the most minimal possible size representation of the XML (which is good for bandwidth), but the data can be stored and processed directly in its EXI form. So not only will you not have the added overhead associated with data compressors, but processing will actually be significantly faster in this new binary form than in it's plain-text XML representation. According to Schneider, "on average, 12 to 14 times faster than processing normal XML." The way I see it, even if EXI in the real world doesn't even come close to their estimates, it'll still be hella-fast.
The best part about this whole thing is that, chances are, us programmers won't have to do a thing to take advantage of EXI. John says it will be embedded at the lowest level of the XML stack, in the parser or serializer, so your Web server will do all the work for you.
Read: W3C
Read: XML Developer
The web is abuzz with talk of Google's new mobile OS, Android. What I find interesting is the stark contrast between Apple's tyrannical stance against people developing their own apps for the iPhone, and Google's stance that outside apps can only lead to the melioration of their product. Apple has blocked users from developing apps for the iPhone, going as far as causing all outside apps that were developed for the iPhone to be bricked. Google has done quite the opposite. Their new Android mobile operating system not only is designed specifically to allow programmers to produce apps for it easily and is not tied to any specific phone or carrier, but the entire operating system will be made open-source sometime next year!
For those of you guys that missed it, Google today announced that they are in fact not making a cellphone or mobile device, but instead were actually developing an open-source operating system for cellphones and mobile devices. The software is known as Android. C'mon, are you really surprised that a software company developed software and not a device? Here's the scoop on Android:
Labels: Apple, Coding, Google, Mobile, Web 3.0
One of the best things about my favorite repository tool TortoiseSVN is how it displays the little overlay icons in over files and folders in Windows Explorer to indicate their status in your Subversion repository. Unfortunately I couldn't figure out how to get these little icons to show up in my favorite file browser Total Commander (formerly Windows Commander.) That is, until now.
In Windows Commander go to Configuration>Options>Display and check the "Show overlay icons, e.g. for links" checkbox, then click Ok. It's the last option under "File display" as shown in the image above. Now you'll see those pretty little icons in any folders you have Checked Out from your repository using TortoiseSVN.
Einstein once said, "Make everything as simple as possible, but not simpler." To help me keep track of the time I spend working on a particular project, I wrote a simple little app called Simple Work Timer (or SWT.) It is the simplest of devices but a piece of software that I use more than just about any other program.
All it is is a little window with 4 buttons. The top one displays the hours, minutes and seconds since the timer was started. The second button displays the amount of time that has passed in hours (for example this button would show 1.5 after 1 and a half hours.) The third button starts and pauses the timer. The last button resets the timer to zero.
Clicking either of the top two buttons will copy that button's text to your clipboard. I use this most often with the second "hours" button. This allows me to paste the exact time I've spent on a project into Quickbooks or a spreadsheet for tracking and billing my time.
As the timer runs, the title of the program will display the hours and minutes since the timer was started. So, a simple glance down at your taskbar is all you need to take a peek at your current hours. This will also tell you if you forgot to unpause the timer when you went out for your smoke break, since SWT will also append the text "Paused" to it's program title when paused.
Perhaps you occasionally need to have multiple timers running at once. All you have to do is run multiple instances of the program and it will add multiple, independent copies of itself to your desktop. To help me keep track of which timer is which, I always place the timer in the same location on my screen for a particular client. For example, for my (fictional) client Joe's Widgets I always put the timer in the lower-right-hand corner of my screen. That way if I start another timer for another task, I'll always be able to distinguish between it and Joe's timer. I've found that SWT works very well coupled with Launchy, especially when launching multiple timers.
I've provided two links at the bottom of this post. The first link is to download Simple Work Timer. SWT is Windows only and requires version 2.0 of the .NET Framework. If you don't know what that means, don't worry - You probably already have it. If not, follow this link to download and install the Framework. SWT itself doesn't require any installation. It's just one executable file that you can put anywhere on your hard drive and run it.
The second link is to download the source code of SWT. It was originally programmed in VB.NET 1.1 but I've up-converted it to 2.0 for you and translated it to C# as well. Both the VB.Net version and C# version are contained in the solution in their respective folders. Obviously this program is very basic, but it's (fairly) well commented and could be a good learning tool for new developers. Here's some of the things you can learn from this code:
Labels: Coding, Downloads, Neat Stuff, Tips, Windows
If you're a regular subscriber to the Grinn Productions Projects Blog, you've probably noticed the recent changes to the site. These were designed to make it easier to read, to help popularize the blog, and to make our ads more appealing. Here's what we've done:
Labels: Coding, The Company