I often find myself in a scenario where I want customers to be able to select dates, delete items by setting an inactive date to today rather than actually removing something from a database, etc...
Sometimes it helps to only deal in dates, rather than in date/time. Using the GetDate() function in SQL brings back a full date with the time string, but here is a great method to fix that.
declare @somedate = cast(floor(cast(GetDate() as float)) as DateTime)
There are a few other ways to do this, but this one seems to perform the best. Tested with SQL 2008 and works great.
Hat tip too Ben Nadal's blog, more info here-
http://www.bennadel.com/blog/122-Getting-Only-the-Date-Part-of-a-Date-Time-Stamp-in-SQL-Server.htm
A Southwestern adventurer striking out into the badlands of the Midwest for fun, profit, and for a wife who wouldn't move back to the Southwest :)
Tuesday, December 07, 2010
Sunday, November 28, 2010
Google Ads

For the very few of you that straggle across this blog every now and then you might notice that I succumbed and put up some Google ads. I resisted for awhile, but I'm poor, so I figured what the heck. Hey, I made a whopping 20 cents my first week!
But 20 cents is 20 cents. I figure a little sugar will invigorate me to write and post articles that have relevance to folks with code and links that line programmers will find of value. Maybe I can boost that 20 cents to a dollar a week. Multiply that by x number of other blogs and web sites that I have just dying on the vine that I might start working on, and I might make 50 bucks or so. That pays for a few domain names, maybe a book or PDF here or there, and some low end 3D software now and again. I will write/code/post for about six months and see what I can get going.
If ads piss you off I'm with you, they piss me off too. But when in Rome...oh well.
Happy Thanksgiving every one. I had a great one, hope you did too.
Monday, November 01, 2010
AWS Free Usage Tier
The cloud battle heats up! Who benefits? Us! AWS Free Usage Tier
Microsoft HTML5 Tooling...Meet Glimmer
Just found this, haven't played with it, but it is a start of Microsoft's efforts to provide tooling for HTML 5.
Meet Glimmer
Meet Glimmer
Sunday, October 24, 2010
Web Developers / Designers: Who Are we?
I'm not sure how this data was gathered, and I don't vouch for it's accuracy, but I bet it is somewhat ballpark. Take a peak at this web infographic to figure out who all us web designers/developers are
Tuesday, October 19, 2010
Very Cool Web Annotator
I like this. Drag a bookmark to your bookmark bar, and then when you are over any given website, click the link, and start annotating the site.
http://markup.io/
Cool.
http://markup.io/
Cool.
Sunday, October 17, 2010
Decent Rundown of YouTube Software
Wanting to do a little video online are you? Check out Web distortion 's list of useful video software.
Friday, October 15, 2010
Basic Silverlight/.Net Twitter Jason Example
OK, some I'm back into Silverlight again. It actually isn't as bad as I thought, and I'm starting to get jazzed about working with it again. To get my feet wet I found a really basic example of adding some twitter search items to a Silverlight Listbox. After looking at it, ugly XML stared at me defiantly. I like XML for some things, like bloating my code a lot.
I know Twitter can return data in JSON, so I I hacked out the following example of consuming a Twitter search JSON result.
Note you need to add a few namespaces, System.Collections.ObjectModel and the new System.Json namespace.
Here is the meat of a click button even that consumes the Json
You can download the base Silverlight 4 project here-
Download project on 4shared.com
I know Twitter can return data in JSON, so I I hacked out the following example of consuming a Twitter search JSON result.
Note you need to add a few namespaces, System.Collections.ObjectModel and the new System.Json namespace.
Here is the meat of a click button even that consumes the Json
You can download the base Silverlight 4 project here-
Download project on 4shared.com
Thursday, October 14, 2010
My Comments on Silverlight
I was originally going to post this on some blog, but I decided not to for now. So I'll post it here.
First, I'm not a great developer. I'm not a bad developer, I'm a middle of the pack dude. I do some fancy stuff sometimes, actually innovate occasionally, but most often I'm stuck in the day to day duldrums of retrieving data and displaying it in some meaningful way on a screen, and taking a user response and saving it to a data store. A little bling is always good, but often I can only provide two of three things (functionality, quick delivery, and "bling"). Usually the bling suffers under the two of three constraints that I often find myself in. Silverlight and Flash, as far as my world generally goes, are bling.
I love what people do with Flash, but we are Microsoft shop so for RIA we play in the Silverlight world. I built a demo project in Silverlight three, even throwing in some Telerik Silverlight controls for EXTRA bling, and it didn't thrill me. I'm facing doing some serious Silverlight 4 development and now and although I will put my head down, crank the music, and code conquer it, it doesn't thrill me. What does thrill me is compiled Javascript, hardware acceleration for HTML 5, web sockets, etc... I don't really know why that thrills me more. It shouldn't, but it does. I think I for better or for worse represent your average high end Mort low end Elvis developer that Silverlight has to thrill if it is going to survive. It just isn't there yet, maybe version 5 will do it. All I know is that after hacking away in version 3 and walking away from it for a bit, I'm finding myself feet dragging a bit in starting a new project in Silverlight 4. Yesterday in my down time I wrote a little adventure game using javascript, crappy animated gif's, and some CSS in a few hours. I just can't wait to get some more spare time to add sockets and make it multiplayer, add ai/pathing, dialogs, etc... That thrilled the heck out of me. Heck I might even use Silverlight as a bridge for the sockets, I wouldn't mind doing that. But if I tried to do the same thing with Silverlight, I would spend hours and hours in Silverlight 4 and it will not thrill me because I would be less productive and constantly running into issues. I guess it is just me.
Maybe in a few days hacking stuff out I will be in love with Silverlight, but for some reason I have my doubts. Don't get me wrong either. I love Microsoft products. Wouldn't want to be coding in anything else but Visual Studio 2010. Love the new Razor syntax. Everyone hates web forms including myself but I've done some cool stuff with them. But for whatever reason, Silverlight to me (currently) was/is a drag.
I'm really looking forward to see what IE 9 / Google 6 / Firefox 4 come up with.
First, I'm not a great developer. I'm not a bad developer, I'm a middle of the pack dude. I do some fancy stuff sometimes, actually innovate occasionally, but most often I'm stuck in the day to day duldrums of retrieving data and displaying it in some meaningful way on a screen, and taking a user response and saving it to a data store. A little bling is always good, but often I can only provide two of three things (functionality, quick delivery, and "bling"). Usually the bling suffers under the two of three constraints that I often find myself in. Silverlight and Flash, as far as my world generally goes, are bling.
I love what people do with Flash, but we are Microsoft shop so for RIA we play in the Silverlight world. I built a demo project in Silverlight three, even throwing in some Telerik Silverlight controls for EXTRA bling, and it didn't thrill me. I'm facing doing some serious Silverlight 4 development and now and although I will put my head down, crank the music, and code conquer it, it doesn't thrill me. What does thrill me is compiled Javascript, hardware acceleration for HTML 5, web sockets, etc... I don't really know why that thrills me more. It shouldn't, but it does. I think I for better or for worse represent your average high end Mort low end Elvis developer that Silverlight has to thrill if it is going to survive. It just isn't there yet, maybe version 5 will do it. All I know is that after hacking away in version 3 and walking away from it for a bit, I'm finding myself feet dragging a bit in starting a new project in Silverlight 4. Yesterday in my down time I wrote a little adventure game using javascript, crappy animated gif's, and some CSS in a few hours. I just can't wait to get some more spare time to add sockets and make it multiplayer, add ai/pathing, dialogs, etc... That thrilled the heck out of me. Heck I might even use Silverlight as a bridge for the sockets, I wouldn't mind doing that. But if I tried to do the same thing with Silverlight, I would spend hours and hours in Silverlight 4 and it will not thrill me because I would be less productive and constantly running into issues. I guess it is just me.
Maybe in a few days hacking stuff out I will be in love with Silverlight, but for some reason I have my doubts. Don't get me wrong either. I love Microsoft products. Wouldn't want to be coding in anything else but Visual Studio 2010. Love the new Razor syntax. Everyone hates web forms including myself but I've done some cool stuff with them. But for whatever reason, Silverlight to me (currently) was/is a drag.
I'm really looking forward to see what IE 9 / Google 6 / Firefox 4 come up with.
Monday, September 27, 2010
Twitter oAuth SHA1 Digest Class / Webmatrix Helper
*** Update*** For some reason the class wasn't showing up, making this info useless. Fixed.
I've decided to use Twitter's @anywhere Javascript service to integrate Twitter functionality into a website I'm building.
I found it pretty easy to use. I decided to integrate some server side logic once a person logged into my website using Twitter. Knowing that Javascript is pretty easy to spoof, I wanted to explore ways of not taking a given user's Twitter login for granted. I found this cryptic paragraph in the @anywhere documentation listed above.
Once the user has authorized the host site, Anywhere will set a cookie named "twitter_anywhere_identity" that contains the id of the logged in user. You can read this on the server side to learn the user's ID. The format of the cookie is:
user_id:signature
When reading the cookie on the server, you should use the signature to verify that this information has come from Twitter. Calculate the signature by appending the given user_id to your OAuth consumer secret and creating a SHA1 hex digest. If this matches the signature in the identity cookie the user ID is verified. For example, in Ruby:
Digest::SHA1.hexdigest(user_id + consumer_secret)
Ut Oh. I know Twitter tends to not have a lot of examples in .Net floating around. After Googling for a bit I found this excellent article on .Net and SHA1 Interop by Jonathan Cogley-
http://authors.aspalliance.com/thycotic/articles/view.aspx?id=2
After doing a few minor tweeks to Jonathan's base code (name space change from .Net 1.1), I present to you a Twitter oAuth SHA1 Digest class
Usage-
The above class will work with any flavor of .Net. If you want to use the above class as a Webmatrix helper, create a class file, rename it TweetSHADigest.cs, paste over the generated code in the file with the above code. The class file should be in a folder called App_Code.
Once Twitter has made a call back to your web site, you can verify that the cookie set came from twitter like so. You will need your web application's Twitter OAuth consumer secret.
I've decided to use Twitter's @anywhere Javascript service to integrate Twitter functionality into a website I'm building.
I found it pretty easy to use. I decided to integrate some server side logic once a person logged into my website using Twitter. Knowing that Javascript is pretty easy to spoof, I wanted to explore ways of not taking a given user's Twitter login for granted. I found this cryptic paragraph in the @anywhere documentation listed above.
Once the user has authorized the host site, Anywhere will set a cookie named "twitter_anywhere_identity" that contains the id of the logged in user. You can read this on the server side to learn the user's ID. The format of the cookie is:
user_id:signature
When reading the cookie on the server, you should use the signature to verify that this information has come from Twitter. Calculate the signature by appending the given user_id to your OAuth consumer secret and creating a SHA1 hex digest. If this matches the signature in the identity cookie the user ID is verified. For example, in Ruby:
Digest::SHA1.hexdigest(user_id + consumer_secret)
Ut Oh. I know Twitter tends to not have a lot of examples in .Net floating around. After Googling for a bit I found this excellent article on .Net and SHA1 Interop by Jonathan Cogley-
http://authors.aspalliance.com/thycotic/articles/view.aspx?id=2
After doing a few minor tweeks to Jonathan's base code (name space change from .Net 1.1), I present to you a Twitter oAuth SHA1 Digest class
Usage-
The above class will work with any flavor of .Net. If you want to use the above class as a Webmatrix helper, create a class file, rename it TweetSHADigest.cs, paste over the generated code in the file with the above code. The class file should be in a folder called App_Code.
Once Twitter has made a call back to your web site, you can verify that the cookie set came from twitter like so. You will need your web application's Twitter OAuth consumer secret.
Sunday, September 26, 2010
Various CDN's Around the Web
Obviously Google's CDN is what you want to use, as it is another link into the google matrix that helps your page ranks.
Google CDN Dev Guide
Here is a link to add the latest v1.x.x version of jQuery to your page hosted by Google-
http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
There are alternatives though, you can you CDN libraries hosted by Microsoft-
Microsoft Hosted CDN's
And there is the new kid on the block,
cachedcommons.org
Cached commons looks promising as it host A LOT of javascript libraries, not just jQuery.
I'll add more links as I find them.
Google CDN Dev Guide
Here is a link to add the latest v1.x.x version of jQuery to your page hosted by Google-
http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
There are alternatives though, you can you CDN libraries hosted by Microsoft-
Microsoft Hosted CDN's
And there is the new kid on the block,
cachedcommons.org
Cached commons looks promising as it host A LOT of javascript libraries, not just jQuery.
I'll add more links as I find them.
Saturday, September 25, 2010
Simple Twitter @anywhere Login/Logout Custom Button
Here is a simple Twitter @anywhere login logout button jQuery script. Note this assumes you have added your a reference to jQuery and your Twitter anywhere javascripts to your page, as well as having a span somewhere on your page with the id of "lbtn".
This is just to get you started, change and configure as you like.
This is just to get you started, change and configure as you like.
Testing on Mobile Devices
Here is a list of Mobile Testers. If you know of any more please comment and I'll add them to the list.
http://sixrevisions.com/tools/10-excellent-tools-for-testing-your-site-on-mobile-devices/
Some additional ones-
http://sixrevisions.com/tools/10-excellent-tools-for-testing-your-site-on-mobile-devices/
Some additional ones-
Friday, September 24, 2010
Photoshop Resources
Job Review
Job not kicking up your adrenaline enough?
Try this one-
EMBED-Climbing A 1786 Foot Tall Tower - Watch more free videos
:)
Found via the Common Sense Gamer http://commonsensegamer.com/?p=2043
Try this one-
EMBED-Climbing A 1786 Foot Tall Tower - Watch more free videos
:)
Found via the Common Sense Gamer http://commonsensegamer.com/?p=2043
Wednesday, September 22, 2010
10 Online Web Site Speed Profilers
1stwebdesigner's posted a very useful link of 10 online website speed profilers here-
1stwebdesigner's Top 10+ Tools For Profiling Your Websites Speed
Please visit the above link for a more indepth overview of each of the links below. I'm listing them here just for a quick reference.
1stwebdesigner's Top 10+ Tools For Profiling Your Websites Speed
Please visit the above link for a more indepth overview of each of the links below. I'm listing them here just for a quick reference.
- Pingdom Tools
- InternetSuperVision.com
- SearchMetrics.com
- WebsiteOptimization.com’s Web Page Optimizer
- WebSlug.info
- uptrends.com
- OctaGate Site Timer
- webwait.com
- Web Tool Hub Website Speed Test
- iWebTools Speed Test
- http://gtmetrix.com/
Wednesday, September 15, 2010
50 Great Web Based Apps to Replace Desktop Ones
GPU Acceleration in HTML 5
Check this out! Google Chrome demo with GPU acceleration. Expect to see it in Chrome 6?
Also IE9 will have compiled JavaScript. The browser war is back on. Flash? Silverlight? You better do something fantastic else HTML 5 over time will eat your bloated asses for lunch.
Also IE9 will have compiled JavaScript. The browser war is back on. Flash? Silverlight? You better do something fantastic else HTML 5 over time will eat your bloated asses for lunch.
Monday, September 06, 2010
Stored Procedures and Webmatrix
OK, there isn't a whole lot of documentation for using stored procedures with Microsoft.Data in WebMatrix. Here is one way I got one to work, I'm hoping there is a better way.
Example of a post back insert using a stored proc. Note I'm not doing any validation here, and if you use this method do a little research on SQL Injection and guard against it.
Example of a post back insert using a stored proc. Note I'm not doing any validation here, and if you use this method do a little research on SQL Injection and guard against it.
@if (IsPost) {
var LinkName = Request["LinkName"];
var LinkURL = Request["LinkURL"];
string sQ = String.Format("execute dbo.myprocname @LinkName=\"{0}\",
@LinkURL=\"{1}",LinkName, LinkURL);
db.Execute(sQ);
}
Thursday, August 26, 2010
Using Twitter's @anywhere Service on Localhost (and with Web Matrix/IIS Express)
Here is the trick to get Twitter's @anywhere service (http://dev.twitter.com/anywhere) working on your localhost website for development and testing.
1) Don't put a call back url when you register your app.
2) On the link below where you register the call back url for your app, click the add domain link.
3) Add either localhost, 127.0.0.1, or both (may not take 127.0.0.1)
4) In your javascript specify the callback url (localhost, 127.0.0.0/auth.cshtml, whatever. I didn't test this but I think you might even be able to enter ports in (localhost:8080). I ended up setting my web server to run on port 80 (default) so I didn't need to add any ports. If you can't enter ports, you might be stuck having to run your dev web server on port 80 or 8080.
Done. No editing hosts files, nada. Why is this so easy and not documented? I think it is because of a recent change on Twitter's end to loosen things up a bit so you can test your applications. For deployment, you may need to actually enter a call back url for your application. I don't thinks so, but test.
For me I'm working with Web Matrix, and I wanted iis express to run on Port 80. Three things.
1) Turn off/stop your default non-IIS Express web server (apache, dev version of IIS full) so you don't get any conflicts.
2) navigate to where the web matrix exe file is located by opening up a console by typing cmd in the start run menu, then navigate to the path by typing something like cd: c:\mypath\. Once there you can run iis express from the command line (only way right now to specify a port).
type something like iisexpress /path:c\mywebpath\mywebsite\ /port:80
3) Right now you can't have any spaces in the path name. I figure that will be fixed in the next beta or the final release.
1) Don't put a call back url when you register your app.
2) On the link below where you register the call back url for your app, click the add domain link.
3) Add either localhost, 127.0.0.1, or both (may not take 127.0.0.1)
4) In your javascript specify the callback url (localhost, 127.0.0.0/auth.cshtml, whatever. I didn't test this but I think you might even be able to enter ports in (localhost:8080). I ended up setting my web server to run on port 80 (default) so I didn't need to add any ports. If you can't enter ports, you might be stuck having to run your dev web server on port 80 or 8080.
Done. No editing hosts files, nada. Why is this so easy and not documented? I think it is because of a recent change on Twitter's end to loosen things up a bit so you can test your applications. For deployment, you may need to actually enter a call back url for your application. I don't thinks so, but test.
For me I'm working with Web Matrix, and I wanted iis express to run on Port 80. Three things.
1) Turn off/stop your default non-IIS Express web server (apache, dev version of IIS full) so you don't get any conflicts.
2) navigate to where the web matrix exe file is located by opening up a console by typing cmd in the start run menu, then navigate to the path by typing something like cd: c:\mypath\. Once there you can run iis express from the command line (only way right now to specify a port).
type something like iisexpress /path:c\mywebpath\mywebsite\ /port:80
3) Right now you can't have any spaces in the path name. I figure that will be fixed in the next beta or the final release.
Subscribe to:
Posts (Atom)