Thursday, November 15, 2007
Amazon Goes Ajax - New Interface Today
Well, mark today down in UI design for websites and e-commerce. Amazon.com unveiled their new interface and it is Ajax (particular the Dynamic HTML aspect).
Certified E-Mail
Let it be known throughout the land, I received my first ever CERTIFIED e-mail today in Yahoo Mail. Will this be a turning point in web history?
The e-mail was from Build-a-Bear Workshop, so parents of young children are probably going to be the first to notice the trend.
Also see:
http://help.yahoo.com/l/us/yahoo/mail/yahoomail/context/context-08.html
The e-mail was from Build-a-Bear Workshop, so parents of young children are probably going to be the first to notice the trend.
Also see:
http://help.yahoo.com/l/us/yahoo/mail/yahoomail/context/context-08.html
Thursday, November 8, 2007
Apache losing market share to Microsoft IIS?
Wow, I was startled to see this graph!
Apache has around a 10% market share advantage over IIS now, which is the smallest gap between the two since IIS was launched in 1996.
src: Netcraft
Tuesday, November 6, 2007
Idiot's Guide to Implementing Microsoft.Practices.EnterpriseLibrary.ExceptionHandling
A simple tutorial for VB.NET folks.
Get Enterprise Library 3.0
Install.
In your app, add reference to C:\Program Files\Microsoft Enterprise Library 3.1—May 2007\Bin
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
If you con't have an app.config file, add one now (you could have this done for you later, but let's keep it simple).
Now open up "Enterprise Library Configuration", a utility installed along with the Enterprise Library that can be found off the Start menu....
Do File/Open... and point to the app.config file in your app.
Right-click the name of your app, select New... and then "Exception Handling Application Block".
Right-click the newly created tree node (it will have a red stop sign with a white X in it) and select New..Exception Policy. Name this "Global Policy".
Save it.
Now, back in Visual Studio 2005, your Try Catch blocks should be changed to the following pattern:
You should now be able to compile and start playing with the advanced features of the Enterprise Library 3.0 version of the old ApplicationBlocks.
Also see: C# Tutorial.
Get Enterprise Library 3.0
Install.
In your app, add reference to C:\Program Files\Microsoft Enterprise Library 3.1—May 2007\Bin
Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll
Microsoft.Practices.EnterpriseLibrary.Common.dll
If you con't have an app.config file, add one now (you could have this done for you later, but let's keep it simple).
Now open up "Enterprise Library Configuration", a utility installed along with the Enterprise Library that can be found off the Start menu....
Do File/Open... and point to the app.config file in your app.
Right-click the name of your app, select New... and then "Exception Handling Application Block".
Right-click the newly created tree node (it will have a red stop sign with a white X in it) and select New..Exception Policy. Name this "Global Policy".
Save it.
Now, back in Visual Studio 2005, your Try Catch blocks should be changed to the following pattern:
Try
'for testing: Throw New Exception("This is a sample exception.")
'put your real code here
Catch ex As Exception
Dim rethrow As Boolean = Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "Global Policy")
If rethrow Then
Throw
End If
End Try
You should now be able to compile and start playing with the advanced features of the Enterprise Library 3.0 version of the old ApplicationBlocks.
Also see: C# Tutorial.
Thursday, November 1, 2007
I Hate Overloads
I just started working the the replacement for Microsoft's Application Blocks. ExceptionManagement, called Microsoft.Practices.EnterpriseLibrary. Specifically, I'm using the Logging class. Guess how many overloads there are for the Write method? NINETEEN!!! 19 overloads, that's right. Imagine if you did not have Intellisense. In my opinion, overloads undermine the whole organization of Object Oriented Programming (OOP), and are to be used SPARINGLY.
Monday, October 22, 2007
Speech Synthesis with .NET 3.0
Very simple:
Reference System.Speech.dll
Reference System.Speech.dll
Dim synth As New Speech.Synthesis.SpeechSynthesizer
synth.SpeakAsync("Hello world.")
Wednesday, October 3, 2007
C# Using Using for Using Connections
A wise man said, "The using statement declares that you are using a disposable object for a short period of time. As soon as the using block ends, the CLR releases the corresponding object immediately by calling its Dispose() method ".
And I just thought "Using" was syntactical sugar for VBers. *
What this implies is you should do your standard vanilla SQL connection like this:
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"]
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connectionString);
using (conn)
{
conn.Open();
System.Data.SqlClient.SqlParameter param = new System.Data.SqlClient.SqlParameter();
.... etc etc....
}
* Not to be confused with With.
And I'm not sure if Using was available in .NET 1.1
Also:
SQL Server and Oracle connection pooling use a full-text match algorithm. That means any minor change in the connection string will thwart connection pooling, even if the change is simply to reverse the order of parameters or add an extra blank space at the end. For this reason, it's imperative that you don't hard-code the connection string in different web pages. Instead, you should store the connection string in one place—preferably in the <connectionStrings> section of the web.config file.
And I just thought "Using" was syntactical sugar for VBers. *
What this implies is you should do your standard vanilla SQL connection like this:
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"]
System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(connectionString);
using (conn)
{
conn.Open();
System.Data.SqlClient.SqlParameter param = new System.Data.SqlClient.SqlParameter();
.... etc etc....
}
* Not to be confused with With.
And I'm not sure if Using was available in .NET 1.1
Also:
SQL Server and Oracle connection pooling use a full-text match algorithm. That means any minor change in the connection string will thwart connection pooling, even if the change is simply to reverse the order of parameters or add an extra blank space at the end. For this reason, it's imperative that you don't hard-code the connection string in different web pages. Instead, you should store the connection string in one place—preferably in the <connectionStrings> section of the web.config file.
Monday, September 24, 2007
Visual Studio 2005 Code Generation Settings
Microsoft does not acknowledge the existence of an Option Setting in Visual Studio 2005.
I could not find any mention of the Windows Forms Designer, General, Code Generation Settings, Optimized Code Generation setting on MSDN, nor, surpisingly, on Google. It remains a mystery.
I could not find any mention of the Windows Forms Designer, General, Code Generation Settings, Optimized Code Generation setting on MSDN, nor, surpisingly, on Google. It remains a mystery.
Tuesday, September 18, 2007
Flash quick notes
Put this in the Action window (F9) for a movie clip's instance.
onClipEvent(enterFrame){
_x = _root._xmouse;
_y = _root._ymouse;
_alpha = _root._xmouse/10;
_rotation = _root._ymouse/10;
}
onClipEvent(enterFrame){
_x = _root._xmouse;
_y = _root._ymouse;
_alpha = _root._xmouse/10;
_rotation = _root._ymouse/10;
}
Flash quick notes
Put this in the Action window (F9) for a movie clip's instance.
onClipEvent(enterFrame){
_x = _root._xmouse;
_y = _root._ymouse;
_alpha = _root._xmouse/10;
_rotation = _root._ymouse/10;
}
onClipEvent(enterFrame){
_x = _root._xmouse;
_y = _root._ymouse;
_alpha = _root._xmouse/10;
_rotation = _root._ymouse/10;
}
Friday, September 7, 2007
Adoption of Widescreen Monitors
I had a good discussion today with colleagues about the impact of widescreen monitors on application and web design. I am skeptical about the usability of widescreen monitors for readability (due to the well known design principle of narrow text columns increasing readability). I've also noticed that generally stores are discounting widescreens below the cost of standard aspect ration monitors. For all I know, this is because they are having trouble getting rid of them.
Then, seemingly explaining all this, I came across this tidbit:
And I thought it had to do with pushing users to view movies on their computers. Instead, it looks like the marketplace is trying to push users to want to view movies on their computers so that they can sell them the less expensive widescreens.
Or something like that.
Then, seemingly explaining all this, I came across this tidbit:
Philips: Widescreen adoption in LCD monitors not as quick as expected
By: Calvin Shao, Taipei; Carrie Yu, DIGITIMES [Friday 20 January 2006]
Friday, January 20, 2006 15:23
Although panel makers have aggressively pushed widescreen LCD monitor panels, the adoption rate is not expected to proceed as fast as expected, with the penetration rate of the segment now set to increase from 2% in 2005 to 9.8% in 2008, according to Sara Liu, assistant manager of market intelligence, Philips CEBLC-MMFD, Royal Philips Electronics.
Panel makers have rolled out various widescreen monitor panels, as it is more cost-efficient to cut glass substrates from later generation panel plants into widescreen models, rather than into standard (4:3 ratio) panels, sources said.
For example, a sixth-generation (6G) LCD substrate can output four more widescreen 20.1-inch panels than standard 20.1-inch panels. In addition, the utilization rate of the substrate would increase by 15 percentage points to over 90%, the sources indicated.
However, when purchasing monitors, consumers tend to judge the size of a monitor by the height of the model. As a result, widescreen models, which look smaller, may not end up being as attractive to customers, Liu said. In fact, a 16:9 20-inch LCD monitor has a 182 square-inch viewing area, compared with 194 square-inches for a 4:3 20.1-inch model, she added.
Chi Mei Optoelectronics (CMO) was the main producer of 19-inch widescreen LCD monitor panels as of the end of last year. ViewSonic, Acer and CMV all use CMO panels in their 19-inch widescreen LCD monitors.
And I thought it had to do with pushing users to view movies on their computers. Instead, it looks like the marketplace is trying to push users to want to view movies on their computers so that they can sell them the less expensive widescreens.
Or something like that.
Friday, August 10, 2007
Notes from Peepcode tutorial on Prototype.js
Notes from Peepcode tutorial on Prototype.js
ver 1.5.1
$H()
$A()
for Hash Object and Array Objects
var smedly = {ape:'brown',frog:'green'}
smedly.ape
var smedly = $H({ape:'brown',frog:'green'})
smedly.keys()
$A isn't really needed...
var asmedly = ['ape','frog','toad']
asmedly.first()
Element.hide('smedly')
$('smedly').hide()
$('smedly').show()
$$('boldTextCSSclass').invoke('hide')
$$('a').invoke('hide')
Anonymous Functions:
$$('a').each(takesAFunction)
$$('a').each(function(element){element.hide()})
Other selector syntaxes (generally uses CSS):
$$('a,p') selects both a's and p's
$$('div p') selects all p's in a div
$$('img') selects all images
$$('img[alt=mephisto-badge]') selects all images with 'mephisto-badge' as alt parm
--------------------------------------------------------
Modules
This is pure JavaScript. Create modules using Hashes.
var myHash = {mykey:myvalue, mykey2:myvalue2}
Now just put function in for the key:value pairs:
var HandyFunctions = {hideLinks: function(){}, showLinks: function(){}}
var HandyFunctions = {
hideLinks: function(){
$$('a').invoke('hide');
},
showLinks: function(){
$$('a').invoke('show')
}
};
Note: when you call these functions, even though they are Hash keys, make sure to put parentheses at end:
HandyFunction.hideLinks()
Classes
Note: see Yahoo video for painfully in-depth exploration of JavaScript classes.
Prototype makes it simpler. Just use Class.create() !!
They are similar to the Module concept above, but with some added functionality:
initialize,
parameters that can be passed to functions,
and you can use "this" keyword.
var Butter = Class.create()
Butter.prototype = {mykey:myvalue}
Butter.prototype = {
initialize: function(brand) {
this.brand = brand;
this.melted = false;
},
melt: function(){
this.melted = true;
}
}
var parkay = new Butter('Parkay');
Extend
addMethods
See Quirksmode for list of cross-browser behaviors (onmousever, onclick, etc)
ver 1.5.1
$H()
$A()
for Hash Object and Array Objects
var smedly = {ape:'brown',frog:'green'}
smedly.ape
var smedly = $H({ape:'brown',frog:'green'})
smedly.keys()
$A isn't really needed...
var asmedly = ['ape','frog','toad']
asmedly.first()
Element.hide('smedly')
$('smedly').hide()
$('smedly').show()
$$('boldTextCSSclass').invoke('hide')
$$('a').invoke('hide')
Anonymous Functions:
$$('a').each(takesAFunction)
$$('a').each(function(element){element.hide()})
Other selector syntaxes (generally uses CSS):
$$('a,p') selects both a's and p's
$$('div p') selects all p's in a div
$$('img') selects all images
$$('img[alt=mephisto-badge]') selects all images with 'mephisto-badge' as alt parm
--------------------------------------------------------
Modules
This is pure JavaScript. Create modules using Hashes.
var myHash = {mykey:myvalue, mykey2:myvalue2}
Now just put function in for the key:value pairs:
var HandyFunctions = {hideLinks: function(){}, showLinks: function(){}}
var HandyFunctions = {
hideLinks: function(){
$$('a').invoke('hide');
},
showLinks: function(){
$$('a').invoke('show')
}
};
Note: when you call these functions, even though they are Hash keys, make sure to put parentheses at end:
HandyFunction.hideLinks()
Classes
Note: see Yahoo video for painfully in-depth exploration of JavaScript classes.
Prototype makes it simpler. Just use Class.create() !!
They are similar to the Module concept above, but with some added functionality:
initialize,
parameters that can be passed to functions,
and you can use "this" keyword.
var Butter = Class.create()
Butter.prototype = {mykey:myvalue}
Butter.prototype = {
initialize: function(brand) {
this.brand = brand;
this.melted = false;
},
melt: function(){
this.melted = true;
}
}
var parkay = new Butter('Parkay');
Extend
addMethods
See Quirksmode for list of cross-browser behaviors (onmousever, onclick, etc)
JavaScript Hash
var animalColors = {'ape':'black', 'pig':'pink', 'frog':'green'}
alert(animalColors['ape'])
alert(animalColors.ape)
Monday, August 6, 2007
Too Many Stored Procedures
Is there such a thing as Too Many Stored Procedures?
Jeff Atwood at Coding Horror makes some great points that reflect my own thoughts over at:
http://www.codinghorror.com/blog/archives/000117.html
I think SQL Server's Object Explorer needs to have a built-in mechanism for managing the thousands of stored procedures that occupy a database, instead of trusting that a sensible naming convention will be used. In my experience, eventually any naming convention breaks down after time, as new developers and technologies arrive.
Linked to in Atwood's post is this by Frans Bouma, who seems to be the main promoter of cautionary use of Stored Procedures: http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx
Jeff Atwood at Coding Horror makes some great points that reflect my own thoughts over at:
http://www.codinghorror.com/blog/archives/000117.html
I think SQL Server's Object Explorer needs to have a built-in mechanism for managing the thousands of stored procedures that occupy a database, instead of trusting that a sensible naming convention will be used. In my experience, eventually any naming convention breaks down after time, as new developers and technologies arrive.
Linked to in Atwood's post is this by Frans Bouma, who seems to be the main promoter of cautionary use of Stored Procedures: http://weblogs.asp.net/fbouma/archive/2003/11/18/38178.aspx
Thursday, August 2, 2007
Quick ASP Log
Handy for debugging errors:
function writeLog(msg)
Dim fso
Dim logfile
Dim logFileName
Dim strLog
logFileName = Server.MapPath("logfile.txt")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set logfile = FSO.OpenTextFile(logFileName, 8, True)
logfile.writeline now() & ":" & msg
set fso = nothing
set logfile = nothing
Dim logfile
Dim logFileName
Dim strLog
logFileName = Server.MapPath("logfile.txt")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set logfile = FSO.OpenTextFile(logFileName, 8, True)
logfile.writeline now() & ":" & msg
set fso = nothing
set logfile = nothing
end function
Wednesday, August 1, 2007
Most Common Validators for ASP.NET
<asp:requiredfieldvalidator id="reqResendWaitDays" Runat="server" ErrorMessage="Required Field" ControlToValidate="txtResendWaitDays"
Display="Dynamic">
</asp:requiredfieldvalidator>
<asp:CompareValidator id="comResendWaitDays" Runat="server" ErrorMessage="Must be numeric" ControlToValidate="txtResendWaitDays"
type="Integer" operator="DataTypeCheck">
</asp:CompareValidator>
Tuesday, July 31, 2007
HTML to Excel with ASP
Quick and Easy method:
Response.Clear
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "inline;filename=requests.csv"
'Response.AddHeader "Content-Disposition", "attachment;filename=requests.csv"
Dim header : header = ""
prefix = false
Dim field
for each field in rs.Fields
if(prefix) then
header = header & ","
end if
header = header & field.Name
prefix = true
next
Response.Write header & vbCRLF & rs.GetString(,,",",,"")
Response.End
Response.Clear
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "inline;filename=requests.csv"
'Response.AddHeader "Content-Disposition", "attachment;filename=requests.csv"
Dim header : header = ""
prefix = false
Dim field
for each field in rs.Fields
if(prefix) then
header = header & ","
end if
header = header & field.Name
prefix = true
next
Response.Write header & vbCRLF & rs.GetString(,,",",,"")
Response.End
IF-THEN-ELSE logic in a SELECT statement
SELECT ename, CASE WHEN sal = 1000 THEN 'Minimum wage'
WHEN sal > 1000 THEN 'Over paid'
ELSE 'Under paid'
END AS "Salary Status"
FROM emp
WHEN sal > 1000 THEN 'Over paid'
ELSE 'Under paid'
END AS "Salary Status"
FROM emp
Monday, July 23, 2007
3 Ways to Reload Page with JavaScript
window.location.reload()
history.go(0)
window.location.href=window.location.href
Friday, July 20, 2007
JavaScript Dynamic Document Creation in New Windows
newtext = document.forms.mainForm("MyTextAreaElement").value;
newwindow = window.open();
newdocument = newwindow.document;
newdocument.write(newtext);
Tuesday, July 17, 2007
Object doesn't support this property or method: 'EOF'
Happens when you forgot to use SET when assigning an object to a variable, e.g.:
set conn = CreateObject("ADODB.Connection") conn.open "<connection string>" rs = conn.execute("SELECT columns FROM table") if not rs.eof then ' error here ' .. |
The line starting with "rs = " should start with "SET rs = " ...
Thursday, July 5, 2007
Using Exists statement in If statements
You'd think there'd be a more elegant way to do this, but...
IF NOT EXISTS(
SELECT TOP 1 1 FROM mytable WHERE myid = @myid
)
BEGIN
...do stuff
END
Monday, July 2, 2007
Annoying Issue with Float and IsNumeric
Warning: When you use IsNumeric in VBScript, it will allow commas to pass. If you don't remove those commas from the string and pass it to a T-SQL procedure which expects a Float, you will get an error "
Error converting data type varchar to float."
Thursday, June 28, 2007
Continuous Marquee or Scroller
// Deluxe Scroller
// Author: Howard Covitz
// Date: May 4, 2007
// All rights reserved, yada yada yada
function startScroller(dn_newsID,scrollWindowHeight,scrollWindowWidth,scrollListHeight,scrollInterval,debug)
{
// Set defaults
if (!dn_newsID){
dn_newsID = 'articleScroller' ;
}
if (!scrollWindowHeight){
scrollWindowHeight = 200 ;
}
if (!scrollWindowWidth){
scrollWindowWidth = 350;
}
if (!scrollListHeight){
scrollListHeight = 900;
}
if (!scrollInterval){
scrollInterval = 30;
}
if (!debug){
debug= false;
}
var n=document.getElementById(dn_newsID);
if(!n){return;}
n.style.height= scrollWindowHeight + 'px'; //sets window height
var c=n.getElementsByTagName('div')[0]; // carOne
var d=n.getElementsByTagName('div')[1]; // carTwo
c.innerHTML = d.innerHTML;
c.style.width= (scrollWindowWidth - 30) + 'px'; //sets data list width, should be less than window width.
d.style.width= (scrollWindowWidth - 30) + 'px'; //sets data list width, should be less than window width.
// var scrollListHeight = c.offsetHeight;
if(debug){
alert(c.offsetHeight);
}
if (c.offsetHeight == 0){ //will hopefully only happen in IE if nested down far
var strContent = c.innerHTML;
//determine character count: strip out HTML tags first
strContent = strContent.replace(/&(lt|gt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">"; });
strContent = strContent.replace(/<\/?[^>]+(>|$)/g, "");
var contentLen = strContent.length;
//following optimized for stylesheet listed later
var charsPerLine = 60;
var lineHeight = 15;
var numItems = 8;
var sepLineHeight = 20;
var buffer = 20;
scrollListHeight = Math.round(((contentLen/charsPerLine) * lineHeight) + (numItems * sepLineHeight) + buffer);
}
else{
scrollListHeight = c.offsetHeight + 15; //pad for firefox????
}
c.scrollInterval = scrollInterval;
c.scrollListHeight= scrollListHeight;
c.scrollWindowHeight = scrollWindowHeight;
if(scrollWindowHeight > scrollListHeight){
//c.dn_startpos= scrollListHeight; // Should be presumed height of data list or window height, whichever is smaller
}
c.dn_scrollpos = c.scrollWindowHeight;
d.scrollInterval = scrollInterval;
d.dn_endpos= scrollListHeight * -2; //double check this logic...maybe this is no longer used below
d.dn_startpos = scrollWindowHeight;//since it is relative positioned, it will line up right after carOne
d.dn_scrollpos = d.dn_startpos;
c.myinterval = setInterval('scrollDOMnews("' + dn_newsID + '")',c.scrollInterval);
c.onmouseover=function(){clearInterval(c.myinterval);}
c.onmouseout=function(){c.myinterval =setInterval('scrollDOMnews("' + dn_newsID + '")',c.scrollInterval);}
d.onmouseover=function(){clearInterval(c.myinterval);}
d.onmouseout=function(){c.myinterval =setInterval('scrollDOMnews("' + dn_newsID + '")',c.scrollInterval);}
}
function scrollDOMnews(dn_newsID)
{
var c=document.getElementById(dn_newsID).getElementsByTagName('div')[0];
c.style.top=c.dn_scrollpos+'px';
if(c.dn_scrollpos== Math.round((c.scrollListHeight * -1))){ //ie -700
c.dn_scrollpos=c.scrollListHeight; //directly below car two
}
c.dn_scrollpos--;
scrollDOMnews2(dn_newsID);
}
function scrollDOMnews2(dn_newsID)
{
var c=document.getElementById(dn_newsID).getElementsByTagName('div')[1];
c.style.top=c.dn_scrollpos+'px';
if(c.dn_scrollpos==Math.round(c.dn_endpos)){
c.dn_scrollpos= 0;
}
c.dn_scrollpos--;
}
/* stop scroller when window is closed */
window.onunload=function()
{
// this will have to be a nice to have:
//clearInterval(dn_interval);
}
/*
EXPECTED FORMAT OF HTML
<div class="marquee" id="articleScroller" style="overflow:hidden;postion:relative;">
<div style="position:relative;"></div>
<div style="position:relative;">
{CONTENT GOES HERE -- just don't use DIV tags}
</div>
</div>
USAGE:
startScroller("articleScroller",200,350,30);
startScroller("articleScroller2",200,350,30);
In IE, optimized for following styles:
.marquee{
padding:0px;
margin:0px;
}
.marquee ul{
margin:0px;
padding:0px;
}
.marquee li{
padding-bottom:3px;
margin:0px;
}
.marquee li a:link, .marquee li a:visited {
font: 11px Arial, Verdana, sans-serif;
text-decoration:underline;
font-weight:bold;
}
.marquee li a:hover, .marquee li a:active {
font: 11px Arial, Verdana, sans-serif;
text-decoration: none;
font-weight:bold;
}
.marquee p{
padding:0px;
margin:0px;
}
*/
Labels:
continuous marquee,
continuous scroller,
JavaScript,
marquee,
scroller
Stripping out HTML tags with JavaScript
strContent = strContent.replace(/&(ltgt);/g, function (strMatch, p1){
return (p1 == "lt")? "<" : ">"; });
strContent = strContent.replace(/<\/?[^>]+(>$)/g, "");
return (p1 == "lt")? "<" : ">"; });
strContent = strContent.replace(/<\/?[^>]+(>$)/g, "");
Monday, June 25, 2007
A quick aside on web culture
I recently started checking out the notorious MySpace and Facebook some more. About a year ago I checked them out just to make sure I was up on the latest Big Thing in my industry (since I am a web programmer, after all). I think at that time you had to have a valid University e-mail, so luckily I had my Brown alumni one. But then recently I read this Facebook for Fiftysomethings at one of my daily reads (Slate.com, I regularly check out the Human Nature column, not to mention the political stuff), which motivated me to the extent that, if Emily Yoffe could do it, so could I (though in retrospect she does seem so naive). Especially in the past month, I've been trying to be more active about "participating", and as will be no surprise to those familiar with both sites, Facebook was more to my taste. Well, on the heels of that realization, I read this today:MySpace, Facebook mirror class divisions in US society.
This just confirms my own observations.
Also, isn't "Social Networking" redundant?
This just confirms my own observations.
Also, isn't "Social Networking" redundant?
Labels:
"social networking",
Facebook,
MySpace
Monday, June 18, 2007
Friday, June 15, 2007
T-SQL Searching through the schema
For SQL Server 2005:
Some examples:
select * from sys.objects
select * from sys.sql_modules <-- Stored Procedures and Views
select * from sys.columns
select * from sys.triggers
Searching the text of all stored procedures:
select o.name from sys.sql_modules m
inner join sys.objects o
on m.object_id = o.object_id
where m.definition like '%string you are looking for%'
Searching for tables that contain the column (field) you want:
select a.name
from sys.objects a
inner join sys.columns b
on a.object_id = b.object_id
where b.name='column name you are looking for'
Another way:
For SQL Server 2000:
Searching the text of all stored procedures:
select object_name(id)
from syscomments
where objectproperty(id,'IsProcedure') = 1
and [text] like '%string you are looking for%'
To search across multiple DATABASES for a particular TABLE:
sp_MSforeachdb 'SELECT "?" AS DB, * FROM [?].sys.tables WHERE name like ''%tablenameyouarelookingfor%'''
or if that undocumented proc is not avail, try this:
Some examples:
select * from sys.objects
select * from sys.sql_modules <-- Stored Procedures and Views
select * from sys.columns
select * from sys.triggers
Searching the text of all stored procedures:
select o.name from sys.sql_modules m
inner join sys.objects o
on m.object_id = o.object_id
where m.definition like '%string you are looking for%'
Searching for tables that contain the column (field) you want:
select a.name
from sys.objects a
inner join sys.columns b
on a.object_id = b.object_id
where b.name='column name you are looking for'
Another way:
SELECT ROUTINE_NAME, ROUTINE_DEFINITION FROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%foobar%' AND ROUTINE_TYPE='PROCEDURE' |
For SQL Server 2000:
Searching the text of all stored procedures:
select object_name(id)
from syscomments
where objectproperty(id,'IsProcedure') = 1
and [text] like '%string you are looking for%'
To search across multiple DATABASES for a particular TABLE:
sp_MSforeachdb 'SELECT "?" AS DB, * FROM [?].sys.tables WHERE name like ''%tablenameyouarelookingfor%'''
or if that undocumented proc is not avail, try this:
DECLARE
@SQL NVARCHAR(
max
)
SET
@SQL = stuff((
SELECT
'
UNION
SELECT '
+ quotename(
NAME
,
''
''
) +
' as Db_Name, Name collate SQL_Latin1_General_CP1_CI_AS as Table_Name
FROM '
+ quotename(
NAME
) +
'.sys.tables WHERE NAME LIKE '
'%'
' + @TableName + '
'%'
''
FROM
sys.databases
ORDER
BY
NAME
FOR
XML PATH(
''
)
,type
).value(
'.'
,
'nvarchar(max)'
), 1, 8,
''
)
--PRINT @SQL;
EXECUTE
sp_executeSQL @SQL
,N
'@TableName varchar(30)'
,@TableName =
'items'
To find out the dates of last modified and created for Stored Procs
SELECT name, create_date, modify_date
FROM sys.objects
WHERE type = 'P'
ORDER BY modify_date DESC
Wednesday, June 13, 2007
Stylesheet based on existence of Javascript
To help deal with those with Javascript disabled on their browsers:
<noscript>
<LINK REL="stylesheet" href="nojavascript.css">
</noscript>
<script language="JavaScript">
<!--
if (document.images){
document.write("<link rel='stylesheet' href='javascript.css'>");
}
//-->
</script>
This is helpful when using CSS properties like "display:none" and
"display:block" with JavaScript to hide Divs.
Tuesday, June 12, 2007
Getting index value of new record created
In your T-SQL stored procedure, after you insert the new record into a table that has an auto-incrementing index, use the following:
SELECT NEWID = SCOPE_IDENTITY()
OR (if using pre 2000 sql server)
select returnval = @@identity
You can retrieve the value in the following way:
set rs = con.Execute(strSql)
yournewID = rs(0)
*UPDATE 2017*
SELECT NEWID = SCOPE_IDENTITY()
OR (if using pre 2000 sql server)
select returnval = @@identity
You can retrieve the value in the following way:
set rs = con.Execute(strSql)
yournewID = rs(0)
*UPDATE 2017*
|
Friday, June 8, 2007
Recent Projects
My manager is really impressed with a documentation tool I created in C#. The mechanics of it were no big deal (aside from getting ASP.NET to behave). But I did have to get real crafty in getting at and creating the data. Used a whole grab bag of tricks to mine it. Sometimes regular expressions, sometimes Textpad features, sometimes just Excel.
Sketchpad for Blogs
I've been wanting to transfer my vast notebook of programming notes, gathered from about 7 years of work, to a blog. Problem is, I intersperse my text with sketches or doodles that server as important memory tags. I know there have been online sketching apps around for years (usually done in Flash), where you can even save the stuff online. So it would seem an easy leap to make that part of a blog. But I've been looking around for about a week and nobody seems to have done this.
This exercise also made me realize how little we've come in truly integrating sketching and word processing, regardless of online or not. It should be a lot simpler now for users of MS Word to add a sketch, but it is poorly integrated.
http://www.zefrank.com/scribbler/
http://www.sketchswap.com/
http://www.cumulatelabs.com/cumulatedraw/
http://www.benettonplay.com/toys/flipbook/flipbook_maker.php
Perhaps due to some synchronicity, though, I did just find this new post, which is tantalizingly close to what I'm talking about.
Julie Lerman Blog - Embedding Silverlight Annotation in my dasblog post
(which references http://silverlight.net/Samples/1.1/Scribbler/run/default.html)
Note that it dovetails with another fascination of mine: the demise of Flash.
This exercise also made me realize how little we've come in truly integrating sketching and word processing, regardless of online or not. It should be a lot simpler now for users of MS Word to add a sketch, but it is poorly integrated.
http://www.zefrank.com/scribbler/
http://www.sketchswap.com/
http://www.cumulatelabs.com/cumulatedraw/
http://www.benettonplay.com/toys/flipbook/flipbook_maker.php
Perhaps due to some synchronicity, though, I did just find this new post, which is tantalizingly close to what I'm talking about.
Julie Lerman Blog - Embedding Silverlight Annotation in my dasblog post
(which references http://silverlight.net/Samples/1.1/Scribbler/run/default.html)
Note that it dovetails with another fascination of mine: the demise of Flash.
Progressive Enhancement
I'm currently digesting an article on Progressive Enhancement as a an alternative approach to web design, as opposed to Graceful Degradation. It turns out I've been a natural P.E. adopter and just never knew it.
Subscribe to:
Posts (Atom)