by James Climer
25. August 2010 16:19

Pomodoro Timer
Written by: James Climer (http://www.climers.com)
I've decided to start using the Pomodoro technique in hopes of making better use of my time. After trying it out for a couple of days I've found it actually helps quite a bit in getting stuff done. I decided to make a little timer for windows because I couldn't find a simple one to download (at least not from a site that I trust).
The Pomodoro Technique™ was developed by Francesco Cirillo and can be found online at http://www.pomodorotechnique.com/. The Pomodoro Timer is a Microsoft Windows Application written in .NET (3.0 Framework) to be used with the Pomodoro technique as a tool to help track time. It is a very simple application but serves its purpose well. The time and audio can be configured via the Promodoro.exe.config file included with the application. The config file also includes instructions in the comments to help make these modifications.
I hope you enjoy this tool and that it helps you make better use of your time.
-James
by James Climer
9. March 2009 14:23
I doubt I'll ever use this again, but regardless I'll post it anyway. I had two datatables, each containing one row that I wanted to compare. So I copied the second datatable row to the first and wrote a function to "rotate" the table counter-clockwise (moving the header row to the left column and each row appearing vertically as addtional columns):
/// <summary>
/// Rotate a table by making the header row the first column and each
/// additional row a new column.
/// </summary>
/// <param name="dataTable"></param>
/// <returns></returns>
protected DataTable RotateDataTable(DataTable dataTable)
{
DataTable dt = new DataTable(dataTable.TableName);
if (dataTable.Rows.Count > 0)
{
// Make a column for the header
dt.Columns.Add();
foreach (DataColumn col in dataTable.Columns)
{
dt.Rows.Add(col.ColumnName);
}
int rowIndex = 0;
foreach (DataRow dr in dataTable.Rows)
{
// Add a column for each row
dt.Columns.Add();
rowIndex++;
for (int colIndex = 0; colIndex < dataTable.Columns.Count; colIndex++)
{
dt.Rows[colIndex][rowIndex] = dataTable.Rows[rowIndex - 1][colIndex];
}
}
}
return dt;
}
by James Climer
24. February 2009 11:58
I've had to write this function a few times to find various controls on a form. Once again, I thought I'd share:
private Control FindControl(Control searchControl, string id)
{
if (searchControl.ID != null)
{
if (searchControl.ID == id)
{
return searchControl;
}
}
foreach (Control childControl in searchControl.Controls)
{
Control control = FindControl(childControl, id);
if(control != null)
{
return control;
}
}
// Not found
return null;
}
This function recursively searches through all child controls of child controls until it finds one that matches the id passed. This breaks down in the event that more than one child control has the same id. But, if you're sure the id is unique, this will work just fine. The following is an example of how I use it:
Button submitButton = (Button)FindControl(this.Page, "SearchButton");
// If a submit button is found, call it
if (submitButton != null)
{
SearchButtonClick(submitButton, null);
}
by James Climer
17. February 2009 08:34
You would think such a common task would be included in the .NET framework, and maybe it is and I just couldn't find it. There are many samples online where people use Excel to do this, and that just seems like a waste to have to include such a huge library (and possibly even install MS Excel on a server) just to get a csv file. So, with that in mind I wrote the following C# class:
Download CSVUtil.cs.zip (1.49 kb)
I used the following as a premise:
- Each record is one line - Line separator may be LF (0x0A) or CRLF (0x0D0A), a line seperator may also be embedded in the data (making a record more than one line but still acceptable).
- Fields are separated with commas.
- Leading and trailing whitespace is ignored - Unless the field is delimited with double-quotes in that case the whitespace is preserved.
- Embedded commas - Field must be delimited with double-quotes.
- Embedded double-quotes - Embedded double-quote characters must be doubled, and the field must be delimited with double-quotes.
- Embedded line-breaks - Fields must be surounded by double-quotes.
- Always Delimiting - Fields may always be delimited with double quotes, the delimiters will be parsed and discarded by the reading applications.
- Fields with leading or trailing spaces must be delimited with double-quote characters.
- Fields may always be delimited with double quotes.
- The first record in a CSV file may be a header record containing column (field) names.
There is nothing special about the code, so I wont bother going into detail about it. This simple class will convert the datatable to a huge csv string that will need to either be written to a file or streamed back to a client over a browser.
by James Climer
30. December 2008 13:52
This one bugged me for a while. It was not obvious because the stored procedure I was calling had so many parameters that I couldn't track down the offending one. Here is the error I got:
PLS-00306: wrong number or types of arguments in call to '<SP NAME>'ORA-06550:
So after counting parameters and verifying spelling over and over I noticed the null values being passed. To pass these values you need to either create a parameter and set the value to DBNull.Value or set it to String.Empty.
by James Climer
30. December 2008 11:26
Error Message:
ORA-06550: line 1, column 528:
PLS-00103: Encountered the symbol ">" when expecting one of the following:
. ( ) , * @ % & = - + < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like
between || multiset member SUBMULTISET_
ORA-06550: line 1, column 528:
PLS-00103: Encountered the symbol ">" when expecting one of the following:
. ( ) , * @ % & = - + < / > at in is mod remainder not rem
<an exponent (**)> <> or != or ~= >= <= <> and or like
between || multiset member SUBMULTISET_
I looked around online and couldn't find a solution for this one, but eventually saw my folly and decided to share.
I was using the following code (generalized for this post) to call an insert stored procedure in Oracle:
#region Database Functions
public void ExecuteNonQuery(string commandText, CommandType commandType, params OleDbParameter[] parameters)
{
using (OleDbConnection conn = new OleDbConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand(commandText, conn))
{
cmd.Parameters.AddRange(parameters);
cmd.CommandType = commandType;
cmd.ExecuteNonQuery();
}
}
}
#endregion
I was trying to use the built-in OleDB .NET library to talk to my Oracle Database and had:"Provider=msdaora" appended to the end of my connection string. (I typically use MS SQL Server, and I didn't have my Oracle hat on today (it's buried somewhere under a pile of clothes in the closet))
So I instead, switched to System.Data.OracleClient and removed the provider from my connection string.
So my code turned into this:
#region Database Functions
public void ExecuteNonQuery(string commandText, CommandType commandType, params OracleParameter[] parameters)
{
using (OracleConnection conn = new OracleConnection(System.Configuration.ConfigurationManager.ConnectionStrings["MyConnectionString"].ConnectionString))
{
conn.Open();
using (OracleCommand cmd = new OracleCommand(commandText, conn))
{
cmd.Parameters.AddRange(parameters);
cmd.CommandType = commandType;
cmd.ExecuteNonQuery();
}
}
}
#endregion
I then ran into another problem, which I'll blog next.
by James Climer
23. December 2008 08:25
I feel a rant coming on, so it might as well go here. The problem with technology advancing so fast is that it is just too darn hard to keep up with.
For instance, at times I have learned Flash and created animations or presentations for different projects. When I got into the projects and actually had time to study, I got pretty good with ActionScript and learned tricks for animating and adjusting audio. But see, then I'll go about a year without using what I've learned. And then, because I have some history with Flash, I'll get another project that requires some Flash application to be written, and sure enough, by then a new version of Flash is out, and the tricks I learned have become obsolete and there are new tools that automate those things.
This should be a good thing, right? But I have to say I find it incredibly frustrating.
Like, I need to make a simple presentation. But Flash has gone through 2 revisions since I last used it and the new version costs too much, and after paying for MSDN licenses, employers don't want to spend anymore on development software. Silverlight scares me, though, because I am not convinced it will be the ubiquitous alternative to Flash that Microsoft is claiming it will be. And sure enough, if I learn it now, then next year when I have to use it again, there will be some new Visual Studio plug-in that makes everything I learned obsolete.
Now, you're probably thinking, "Dude! That is how this business works, what are you whining about?" I know! I know! I'm a whiner when it comes to this--it's just frustrating! I don't think employers want to pay for me to research and learn about these tools, but without spending a quarter of your time training, it's impossible to keep up.
I'm going to keep working on that though!