// could not find simple example of setting line colors in Flot graph
var lcolors = ["#FFA500","#00BFFF","#DC143C","#3CB371"];
// get the data after graph is plotted, change line colors, then redraw
var plot = $.plot($("#placeholder"), data, getOptions());
series = plot.getData();
for (var i = 0; i < series.length; ++i) {
if (i < lcolors.length) {
series[i].color = lcolors[i]; // override the default color
}
}
plot.draw();
// options for time series graph with live refresh
function getOptions() {
return {
// drawing is faster without shadows
series: {
shadowSize: 0
},
lines: {
show: true
},
grid: {
hoverable: true,
clickable: true
},
legend: {
show: false,
backgroundOpacity: 0,
position: 'nw'
},
xaxis: {
mode: 'time',
max: new Date().getTime() - (new Date().getTimezoneOffset() * 60000),
timeformat: "%H:%M%p"
},
yaxis: {
min: 0,
tickFormatter: function suffixFormatter(val, axis) {
return val.toFixed(axis.tickDecimals);
}
}
};
}
Sunday, May 6, 2012
Saturday, April 28, 2012
HP Pavillion dv7t instructions for enabling function keys to work when pressed
as of April 28th, 2011 the instructions on HP website are backwards, I had to select DISABLED to get my Function keys to work normally on my hp dv7t laptop
Who the heck thought of disabling the function keys as the default?
Who the heck thought of disabling the function keys as the default?
Friday, March 30, 2012
Gmail Basic HTML view looks restores the old Gmail interface
Just learned you can restore the old gmail interface by switching to basic HTML view.
Click this link to open Gmail in basic view or just add the ui=html flag to your URL, i.e. https://mail.google.com/mail/?ui=html
The fact that this disables Chat and a bunch of other nuisances just adds to the benefit.
Click this link to open Gmail in basic view or just add the ui=html flag to your URL, i.e. https://mail.google.com/mail/?ui=html
The fact that this disables Chat and a bunch of other nuisances just adds to the benefit.
Wednesday, September 1, 2010
Sorting sub-directories using IComparer in Visual Basic .NET
First we create an IComparer class:
Imports System.IO
Public Class DirectoryCompare
Implements IComparer
Public Overridable Overloads Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
Dim objX As DirectoryInfo = CType(x, DirectoryInfo)
Dim objY As DirectoryInfo = CType(y, DirectoryInfo)
Return objX.Name.CompareTo(objY.Name)
End Function
End Class
And some code showing how to use it:
Dim dArray() = New DirectoryInfo("C:\\Results").GetDirectories
If Not dArray Is Nothing Then
Dim dc As New DirectoryCompare()
Dim dirs As ArrayList = New ArrayList(dArray)
dirs.Sort(dc)
dim lastDirPath as String = CType(dirs(dArray.Length - 1), DirectoryInfo).FullName
'step through
For Each dir As DirectoryInfo In dArray
Next
'step backwards
For idir As Integer = dArray.Length - 1 To 0 Step -1
Dim dir As DirectoryInfo = CType(dirs(idir), DirectoryInfo)
Next
End If
Imports System.IO
Public Class DirectoryCompare
Implements IComparer
Public Overridable Overloads Function Compare(ByVal x As Object, ByVal y As Object) As Integer Implements IComparer.Compare
Dim objX As DirectoryInfo = CType(x, DirectoryInfo)
Dim objY As DirectoryInfo = CType(y, DirectoryInfo)
Return objX.Name.CompareTo(objY.Name)
End Function
End Class
And some code showing how to use it:
Dim dArray() = New DirectoryInfo("C:\\Results").GetDirectories
If Not dArray Is Nothing Then
Dim dc As New DirectoryCompare()
Dim dirs As ArrayList = New ArrayList(dArray)
dirs.Sort(dc)
dim lastDirPath as String = CType(dirs(dArray.Length - 1), DirectoryInfo).FullName
'step through
For Each dir As DirectoryInfo In dArray
Next
'step backwards
For idir As Integer = dArray.Length - 1 To 0 Step -1
Dim dir As DirectoryInfo = CType(dirs(idir), DirectoryInfo)
Next
End If
Thursday, August 26, 2010
Table Adapters invalid and cannot be generated after altering ODBC Firebird database
I may have generated a unique cause for this error, but it's a scary moment when all your ODBC table adapter queries disappear so I'll document the experience.
This Visual Basic.Net (2008) project started out with an Access database for convenience, and I prefer mixed case table and field names for legibility.
About 10 days ago I switched to a Firebird database, and it was pretty cool that the table adapters worked with Firebird after minor edits (e.g. remove the back-quotes on field names, handle missing native boolean type in Firebird)
But, today after adding some columns in the Firebird database all my table adapters disappeared. The error is briefly summarized as "Failed to generate code. No mapping exists from DbType Object to a known OdbcType" The IDE showed "unknown type" critical errors on every reference in code.
This error would occur even though I could hit Execute Query in the Table Adapter designer and see valid data appear.
After some thrashing and a restore of all the relevant Dataset files from backup I figured out the error was rooted in case-sensitivity. One of the table adapters could no longer reference it's underlying table, and that meant the code for all the table adapters in the class could not be generated. Interestingly, in dataset design view the obviously broken adapter was *not* on the table with the new columns.
There appeared to be problems in the <Mappings> for the newly altered table. I saw both mixed-case to mixed-case and upper-case to upper-case mappings, but no mixed-case to upper-case mappings. In addition, the column types were declared differently in mixed case from upper case, probably because they were based on Access when first generated, and Firebird when regenerated.
This was going to be a problem because all the queries were written in mixed case, but Firebird stores all field and table names in upper case (unless you quote each field and table name, which I figured is only going to cause problems later), so there was no possible way to map the text in the commands and field definitions to the Firebird interface.
After converting queries and fields on the broken table adapter to upper case, and eliminating conflicting mapping statements and using all upper case in the newly altered table, the table adapters all work again. For safety I converted all the other table adapters to upper case as well.
It looked like the behind-the-scenes work to incorporate the newly added columns had a problem with the mixed case of the fields. All the columns of the table were there in upper case
One symptom you can look for is the field list in the table adapter disappears, all that's left is a list of queries. A second symptom which I missed because the relevant table has 30+ fields is that field names are listed twice, once in mixed case and once in all upper.
Another symptom is after doing Configure on any query in the table adapter you get the "unable to convert object to a known ODBC type" error when you hit Finish.
Since the case and field type issues were a result of moving from Access to Firebird I'm not sure how many people are going to run into this. Bottom line, if you think your going to adopt Firebird later then declare everything in upper case to start with or prepare to comb your code for case-dependencies.
This Visual Basic.Net (2008) project started out with an Access database for convenience, and I prefer mixed case table and field names for legibility.
About 10 days ago I switched to a Firebird database, and it was pretty cool that the table adapters worked with Firebird after minor edits (e.g. remove the back-quotes on field names, handle missing native boolean type in Firebird)
But, today after adding some columns in the Firebird database all my table adapters disappeared. The error is briefly summarized as "Failed to generate code. No mapping exists from DbType Object to a known OdbcType" The IDE showed "unknown type" critical errors on every reference in code.
This error would occur even though I could hit Execute Query in the Table Adapter designer and see valid data appear.
After some thrashing and a restore of all the relevant Dataset files from backup I figured out the error was rooted in case-sensitivity. One of the table adapters could no longer reference it's underlying table, and that meant the code for all the table adapters in the class could not be generated. Interestingly, in dataset design view the obviously broken adapter was *not* on the table with the new columns.
There appeared to be problems in the <Mappings> for the newly altered table. I saw both mixed-case to mixed-case and upper-case to upper-case mappings, but no mixed-case to upper-case mappings. In addition, the column types were declared differently in mixed case from upper case, probably because they were based on Access when first generated, and Firebird when regenerated.
This was going to be a problem because all the queries were written in mixed case, but Firebird stores all field and table names in upper case (unless you quote each field and table name, which I figured is only going to cause problems later), so there was no possible way to map the text in the commands and field definitions to the Firebird interface.
After converting queries and fields on the broken table adapter to upper case, and eliminating conflicting mapping statements and using all upper case in the newly altered table, the table adapters all work again. For safety I converted all the other table adapters to upper case as well.
It looked like the behind-the-scenes work to incorporate the newly added columns had a problem with the mixed case of the fields. All the columns of the table were there in upper case
One symptom you can look for is the field list in the table adapter disappears, all that's left is a list of queries. A second symptom which I missed because the relevant table has 30+ fields is that field names are listed twice, once in mixed case and once in all upper.
Another symptom is after doing Configure on any query in the table adapter you get the "unable to convert object to a known ODBC type" error when you hit Finish.
Since the case and field type issues were a result of moving from Access to Firebird I'm not sure how many people are going to run into this. Bottom line, if you think your going to adopt Firebird later then declare everything in upper case to start with or prepare to comb your code for case-dependencies.
Case-insensitive sorting of Firebird field in a Visual Basic web application
I wanted to sort elements in a ListBox alphabetically without regard to case. However, Firebird does a case-sensitive sort, and I couldn't get it to recognize UPPER() in the SELECT statement.
One solutions is to add the rows in the table adapter data table to an array of elements of a custom class. The custom class implements IComparable, so when you do Array.sort you can get the case-insensitive order desired. Here's my custom class:
Public Class trendpoint
Implements IComparable
Public name As String
Public description As String
Public Sub New(ByVal name As String, ByVal description As String)
Me.name = name
Me.description = description
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
Dim comparepoint As trendpoint = CType(obj, trendpoint)
If Me.name.ToUpper < comparepoint.name.ToUpper Then
Return -1
ElseIf Me.name.ToUpper > comparepoint.name.ToUpper Then
Return 1
Else
Return 0
End If
End Function
End Class
One solutions is to add the rows in the table adapter data table to an array of elements of a custom class. The custom class implements IComparable, so when you do Array.sort you can get the case-insensitive order desired. Here's my custom class:
Public Class trendpoint
Implements IComparable
Public name As String
Public description As String
Public Sub New(ByVal name As String, ByVal description As String)
Me.name = name
Me.description = description
End Sub
Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
Dim comparepoint As trendpoint = CType(obj, trendpoint)
If Me.name.ToUpper < comparepoint.name.ToUpper Then
Return -1
ElseIf Me.name.ToUpper > comparepoint.name.ToUpper Then
Return 1
Else
Return 0
End If
End Function
End Class
Enable double click event on a ListBox in a vb.net web application
There's a nice concise C# example of supporting double click event on a listbox control in an asp.net web application, here is the equivalent code (for the page load event) in Visual Basic.
If (Not Request.Item("__EVENTARGUMENT") Is Nothing And Request.Item("__EVENTARGUMENT") = "move") Then
Dim idx As Integer = ListBox1.SelectedIndex
Dim item As ListItem = ListBox1.SelectedItem
ListBox1.Items.Remove(item)
ListBox2.SelectedIndex = -1
ListBox2.Items.Add(item)
End If
ListBox1.Attributes.Add("ondblclick", ClientScript.GetPostBackEventReference(ListBox1, "move"))
If (Not Request.Item("__EVENTARGUMENT") Is Nothing And Request.Item("__EVENTARGUMENT") = "move") Then
Dim idx As Integer = ListBox1.SelectedIndex
Dim item As ListItem = ListBox1.SelectedItem
ListBox1.Items.Remove(item)
ListBox2.SelectedIndex = -1
ListBox2.Items.Add(item)
End If
ListBox1.Attributes.Add("ondblclick", ClientScript.GetPostBackEventReference(ListBox1, "move"))
Subscribe to:
Posts (Atom)