tag:blogger.com,1999:blog-27823598324603072582023-08-01T00:14:36.702-04:00Dev HarborWeb application R&D notes, from the world of Java, Flex, CSS, XHTML, Flash, .NET, cross-browser compatibility, JavaScript, AJAX, ADA compliance, Photoshop, and any and all things related to Web development!Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.comBlogger1261125tag:blogger.com,1999:blog-2782359832460307258.post-84267874221985105962016-04-19T10:51:00.000-04:002016-04-19T10:51:13.347-04:00Entity Framework and SQL Server's Time datatypeFor a current WPF project, I needed to store a time value on SQL Server 2008, using its handy <span style="font-family: Courier New, Courier, monospace;">time </span>datatype. For data retrieval, I was using Entity Framework 6 (EF), and my models had been built with database-first; hence the entity models in Visual Studio were automatically generated by EF.<br />
<br />
Interestingly, EF used the .NET <span style="font-family: Courier New, Courier, monospace;">TimeSpan</span> type to map to the SQL Server <span style="font-family: Courier New, Courier, monospace;">time</span> datatype. My view models (for MVVM pattern) had to match the <span style="font-family: Courier New, Courier, monospace;">TimeSpan</span> type as well. This all seemed strange, until I realized there's no .NET <span style="font-family: Courier New, Courier, monospace;">Time</span> type. Regardless of the strangeness, EF successfully converted values between <span style="font-family: Courier New, Courier, monospace;">TimeSpan</span> and SQL Server <span style="font-family: Courier New, Courier, monospace;">time</span>, as documented in <a href="http://thedatafarm.com/data-access/entity-framework-timespan-sql-server-time/" target="_blank">this article</a>.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-22978613199055033692016-03-11T08:12:00.001-05:002016-03-11T08:12:15.302-05:00Block Windows 10 forced updatesThis looks promising in preventing the forced updates: <a href="http://www.infoworld.com/article/3042668/microsoft-windows/block-windows-10-forced-updates-without-breaking-your-machine-part-1.html" target="_blank">Block Windows 10 forced updates without breaking your machine, part 1</a>Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-27691774201587560822016-03-08T16:51:00.000-05:002016-03-08T16:52:40.376-05:00SQL Server: build dynamic WHERE and ORDER BY clausesFor a recent project, I needed to build a dynamic SELECT statement without using lots of IF statements or resort to dynamic SQL statements, with the EXEC statement. Well, some research came to the rescue.<br />
<br />
In my use case, the user chooses a search column from a dropdown box and then provides a search value. So the WHERE clause needs to be dynamic.<a href="http://www.sommarskog.se/dyn-search-2008.html" target="_blank"> This article</a> provided the solution: using a combination of OR and AND statements to account for null values:<br />
<pre class="brush: sql">select * from Employee
where
(lastName = @LastName AND @LastName IS NOT NULL)
OR (employeeID = @employeeID AND @employeeID IS NOT NULL)
OR (securityID = @securityID AND @securityID IS NOT NULL)
order by
case when @LastName is not null then CONVERT(char(50), lastName) + CONVERT(char(50), firstName)
when @employeeID is not null then employeeID
when @securityID is not null then securityID
end</pre>
As for the ORDER BY clause, <a href="http://www.4guysfromrolla.com/webtech/010704-1.shtml" target="_blank">this article</a> solved it. A CASE statement. Note also the multi-value option for the lastName column: I'd like to sort on lastName and then firstName. This is not allowed in an ORDER BY CASE statement; however, thanks to the 4 Guys from Rolla, the trick is to use string concatenation to solve this.
Happy coding!Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-66098030331012964772016-02-15T09:59:00.006-05:002016-02-15T10:00:16.584-05:00Find a column name across all tables on SQL ServerI'm doing a "black box" project, where I need to discover how a vendor app's database works. To that end, I've found this T-SQL useful in searching across the 140 tables for a column name, thanks to the <a href="http://blog.sqlauthority.com/2008/08/06/sql-server-query-to-find-column-from-all-tables-of-database/" target="_blank">tip from Pinal Dave's site</a>,
<br />
<pre class="brush: sql">USE myDatabase
GO
SELECT t.name AS table_name,
SCHEMA_NAME(schema_id) AS schema_name,
c.name AS column_name
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
WHERE c.name LIKE '%ColumnNameToFind%'
ORDER BY schema_name, table_name;</pre>
Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-57266116193166025222016-02-11T16:49:00.001-05:002016-02-11T16:49:26.689-05:00Rename all empty SQL Server tablesI'm working on a large database on the developer server and need a way to sift through and analyze the data. This is for a project where we're going to discard these tables and build a new system; in the meantime, I need to work with the copy of the old data. To that end, I created this T-SQL script to append all empty tables' names with '__EMPTY'.<br />
<pre class="brush: sql">declare @new_name varchar(max), @query varchar(max)
IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp
;WITH TableRows AS
(
SELECT
SUM(row_count) AS [RowCount],
OBJECT_NAME(OBJECT_ID) AS TableName
FROM
sys.dm_db_partition_stats
WHERE
(index_id = 0 OR index_id = 1)
and (LEFT(OBJECT_NAME(OBJECT_ID), 3) <> 'sys')
GROUP BY
OBJECT_ID
)
SELECT * into #temp
FROM TableRows
WHERE [RowCount] = 0
order by TableName
DECLARE db_cursor CURSOR FOR
SELECT tablename
FROM #temp
OPEN
db_cursor
declare @name varchar(max)
FETCH
NEXT FROM db_cursor INTO @name
WHILE (@@FETCH_STATUS = 0)
BEGIN
set @new_name = @name + '__EMPTY'
set @query = 'exec sp_rename ''' + @name + ''',''' + @new_name + ''''
exec(@query)
FETCH NEXT FROM db_cursor INTO @name
END
CLOSE db_cursor
deallocate db_cursor
IF OBJECT_ID('tempdb..#temp') IS NOT NULL DROP TABLE #temp</pre>
I used the technique described in <a href="http://stackoverflow.com/a/5630752/177416" target="_blank">this Stack Overflow post</a> to find the empty tables.
Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-83121755774678430612016-02-05T08:48:00.002-05:002016-02-05T08:48:36.165-05:00SamsaraJS: Famo.us fork juices mobile Web UIsThe library provides native-like app experiences and takes on the mobile Web's performance issues: <a href="http://www.infoworld.com/article/3030235/javascript/samsarajs-famous-fork-juices-mobile-web-uis.html" target="_blank">SamsaraJS: Famo.us fork juices mobile Web UIs</a>Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com1tag:blogger.com,1999:blog-2782359832460307258.post-69359197917972201012016-02-04T13:59:00.001-05:002016-02-04T14:00:37.970-05:00References greyed out in VBA windowI needed to add some references in an Access 2013 code module. Going to Tools, I found the References item greyed out. Research led to <a href="http://blogs.msdn.com/b/cristib/archive/2012/02/29/vba-programmatically-enable-access-to-the-vba-object-model-using-macros.aspx" target="_blank">this article</a> with a registry key to enable References:<br />
<pre class="brush: plain">[HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\Access\Security]
"AccessVBOM"=dword:00000001</pre>
Note that I am an admin on this machine, running Office 2013 (hence the "15.0") and need VBA in Access. You'll need to modify the above to your needs.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com1tag:blogger.com,1999:blog-2782359832460307258.post-80949857737364882812016-01-28T15:49:00.002-05:002016-01-28T15:53:32.666-05:00Angular 1.5 nested views with ASP.NET MVCThis tutorial from Miguel Castro demonstrates a way to create single-page application (SPA) silos in ASP.NET MVC using its server-side routing, and merging that with Angular <span style="font-family: "courier new" , "courier" , monospace;">ng-view</span> directive and routing to simulate nested views.
<br />
<iframe allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/f67PFtrldGQ" style="margin-top: 20px;" width="635"></iframe>Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-1752339878027730102016-01-28T15:04:00.000-05:002016-01-28T15:04:00.017-05:00Great podcast with the Google Angular teamThe Google Angular team sat down for the "Adventures in Angular" podcast, answering a ton of questions about the upcoming Version 2.0: <a href="https://devchat.tv/adventures-in-angular/078-aia-ng-beta-with-brad-green-mi-ko-hevery-and-igor-minar">https://devchat.tv/adventures-in-angular/078-aia-ng-beta-with-brad-green-mi-ko-hevery-and-igor-minar</a>. An interesting tidbit... release date for RC is around March/April time-frame this year.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-59313490256481920262016-01-27T08:21:00.000-05:002016-01-27T08:24:10.772-05:00Disable Chrome sign-in screenChrome has a logon screen that can become annoying. Instructions <a href="https://forums.digitalpoint.com/threads/how-to-disable-sign-into-chrome.2663438/" target="_blank">here</a> provided the answer. To permanently disable it on Windows,<br />
<ol>
<li>Close out of Chrome. </li>
<li>Go to <span style="font-family: "courier new" , "courier" , monospace;">C:\Users\user-name\AppData\Local\Google\Chrome\User Data\Default\</span></li>
<li>Open the Preferences file with Notepad (or other text editor).</li>
<li>Search for <span style="font-family: "courier new" , "courier" , monospace;">"sync_promo"</span></li>
<li>Initially, it will look something like <span style="font-family: "courier new" , "courier" , monospace;">"sync_promo": { "startup_count": 6}</span></li>
<li>Edit it to this: <br /><span style="font-family: "courier new" , "courier" , monospace; font-size: small;">"sync_promo":{"startup_count":6,"user_skipped":true,"view_count":4}</span><br /></li>
<li>Save the file.</li>
<li>Exit the text editor.</li>
<li>Open Chrome. Viola! No more annoying logon screen.</li>
</ol>
Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-35670236081642292492016-01-26T15:58:00.000-05:002016-01-27T08:40:44.499-05:00Stationary corner triangle DIV using CSSEver wanted a triangle DIV that hovers over the page <i>and </i>has a drop shadow? Here's one I built using nothing but CSS 3 and HTML5:
<iframe src="http://jsfiddle.net/jsFiddlePlayer/vhg7csb7/31/embedded/result,css,html" style="border:1px solid #333; height: 300px; width: 100%;"></iframe><br />
To modify the triangle, edit the <span style="font-family: "courier new" , "courier" , monospace;">border-width</span> and <span style="font-family: "courier new" , "courier" , monospace;">border-color</span> on the <span style="font-family: "courier new" , "courier" , monospace;">div#corner-triangle</span>. Read more details on my Stack Overflow <a href="http://stackoverflow.com/a/31818564/177416" target="_blank">answer</a>. You can also use the nifty <a href="http://apps.eky.hk/css-triangle-generator/" target="_blank">CSS Triangle Generator</a>.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-87770895935585515472016-01-26T15:29:00.000-05:002016-01-26T15:31:17.706-05:00Learning Angular quicklyIf you need to get up-to-speed on AngularJS quickly, nothing beats the collection compiled by the always great Aaron Marisi: <a href="http://angularfirst.com/learning-angular-quickly/" target="_blank">Learning Angular Quickly</a>. I'm just getting into the <a href="https://devchat.tv/adventures-in-angular" target="_blank">podcasts</a> he lists, and recommend his resources.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-42929844091070410002016-01-26T15:21:00.000-05:002016-01-26T15:21:00.870-05:00Great beginning Angular tutorialIf you're starting with AngularJS on Visual Studio, look no further than <a href="http://angularfirst.com/" target="_blank">Aaron Marisi's Angular First</a> blog. He explains the basics and some more advanced subjects clearly and simply. Plus he follows best practices and provides the code for all his examples. Lots to learn here!Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-53606320308556897102016-01-26T09:30:00.002-05:002016-01-26T09:30:59.005-05:00Run a program on Windows startupI had a shortcut to a batch file that needed to run on the startup of Windows 10 x64 Enterprise startup. All the various methods described (adding to the Startup folder, adding to regular Run key in registry) didn't work. Finally, <a href="http://stackoverflow.com/a/10201281/177416" target="_blank">this post on Stack Overflow</a> solved the issue. This should work well on other versions of Windows too.<br />
<br />
Because this is a 64-bit Windows, the change has to be made in <span style="font-family: Courier New, Courier, monospace;">Wow6432Node</span>:
<br />
<pre class="brush: plain">HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Run</pre>
There, you can add a new string value, give it a name, and then double-click to edit it. Place the full path of the program in double quotes. If it's something requiring administrator privileges, on startup, Windows will display the UAC dialog.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-4844266211412065742015-08-06T13:34:00.001-04:002015-08-06T13:34:46.003-04:00Nice jQuery plugin for "Read more" text truncatingSpent some time researching options to do "Read more" functionality for text on a web page. Many were based on a preset height in pixel, which cut the text in mid-sentence, without adding any ellipsis. In addition, those which did truncate with ellipsis lacked a flexible animation. Then I found <a href="http://blog.jeremymartin.name/2008/02/jtruncate-in-action.html" target="_blank">jTruncate </a>from jMar's blog. It does the trick on any number of elements on the page via jQuery; it also includes options for animation and more/less link text.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-13266592760050704472015-07-28T21:09:00.000-04:002015-07-28T21:11:14.386-04:00The type or namespace name 'XmlNodeReader' could not be found (are you missing a using directive or an assembly reference?)I had to download a Visual Studio 2015 RC solution to a VM and rebuild it. However, in the process, build errors popped up. They were similar to this one:<br />
<div>
<br /></div>
<div>
<pre class="brush: text">The type or namespace name 'XmlNodeReader' could not be found (are you missing a using directive or an assembly reference?) myapp.DNX Core 5.0</pre>
<div>
<br /></div>
<div>
Lots of research and trial-and-error finally revealed the answer: The <span style="font-family: Courier New, Courier, monospace;">myapp </span>project (an ASP.NET MVC app) had references to two frameworks -- DNX 4.5.1 and DNX Core 5.0. These were listed in the <span style="font-family: Courier New, Courier, monospace;">project.json </span>file:</div>
<div>
<br /></div>
<pre class="brush: jscript">"frameworks": {
"dnx451": {
"frameworkAssemblies": {
"System.Web": "4.0.0.0",
"System.Xml": "4.0.0.0",
"System.Xml.Serialization": "4.0.0.0"
}
}//,
//"dnxcore50": { }
},</pre>
<br />
<div>
<a href="http://stackoverflow.com/questions/29979199/how-to-use-old-dependencies-with-asp-net-5" target="_blank">This article </a>had the answer. I needed to comment out the <span style="font-family: Courier New, Courier, monospace;">dnxcore50</span> in <span style="font-family: Courier New, Courier, monospace;">project.json</span>; once done, the app compiled and all was well with Visual Studio. </div>
</div>
Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-19058598119430271462015-07-20T16:48:00.002-04:002015-07-20T16:48:30.571-04:00Creating a peeling sticker effect in PhotoshopUsed <a href="http://drawne.com/basic-peeling-sticker-effect-in-photoshop/" target="_blank">this great tutorial</a> today to create some peeling stickers for Facebook ads.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-48814529562811887692015-07-17T10:00:00.002-04:002015-07-17T10:00:48.850-04:008 free sites that teach you how to program<a href="http://www.infoworld.com/article/2949214/it-training/8-free-sites-that-teach-you-how-to-program.html">http://www.infoworld.com/article/2949214/it-training/8-free-sites-that-teach-you-how-to-program.html</a>Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-48494606731843057282015-07-17T09:56:00.002-04:002015-07-17T09:58:21.121-04:00Wrapping text around an image in Photoshop<a href="http://pshero.com/photoshop-tutorials/graphic-design/wrapping-text-around-an-object" target="_blank">This article</a> shows how to use the Pen tool to wrap text around an image. <a href="http://www.photoshopessentials.com/photoshop-text/text-effects/text-wrap/" target="_blank">This one</a> covers a similar technique, but using shapes.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-85024363625898547792015-07-01T20:32:00.000-04:002015-07-01T20:54:56.518-04:00Pass arbitrary parameter to partial view in ASP.NET MVCI had a chunk of HTML that needed to repeat in a few places, so it made sense to throw it into a partial view. However, each chunk had to have a unique ID for a Bootstrap collapse component. So a parameter needed to be passed in. Some research revealed a rather simple, elegant way in <a href="http://www.codeproject.com/Tips/898017/Different-Ways-to-Pass-Data-to-Partial-View" target="_blank">this article</a>. Just pass it as the partial view's model:<br />
<br />
<pre class="brush: csharp">@Html.Partial("~/Views/Shared/_TestimonialSubmitPartial", "1")</pre>
<br />
Then, in the partial view, read it using <span style="font-family: Courier New, Courier, monospace;">@Model</span> -- it's the only value passed in, so no dot notation is necessary. Each time I'm using the partial view, I change the value.<br />
<br />
In the partial view, I set the <span style="font-family: Courier New, Courier, monospace;">data-target</span> of the Bootstrap button to the concatenated ID and also set the collapse div to that same value:
<br />
<pre class="brush: xml"><button class="btn btn-default"
data-target="#testimonial-submit-instructions-@Model"
data-toggle="collapse" type="button">
Submit Testimonial
</button>
<div class="collapse" id="testimonial-submit-instructions-@Model">
.....
</div></pre>
Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-44607680342543365052015-06-22T17:34:00.003-04:002015-06-22T17:34:51.085-04:00Use the RGB color profile in PhotoshopFor a project, I needed to submit images to a publisher in RGB. Photoshop, at least the CS5 version, uses a strange, home-brewed color profile called sRGB. The conversion to the correct color profile is described in <a href="http://www.peachpit.com/articles/article.aspx?p=1660185" target="_blank">this informative article</a>, but then, when saving for the web as JPEG, Photoshop wants to convert the colors back to sRGB in the save dialog box (File > Save for Web and Devices > Convert to sRGB). Ensure this checkbox is not marked when saving the file, or your efforts might be for naught. Also, it's a good idea to check the box for "Embed color profile" for JPG file format when saving publication-quality files.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-79558799042441356602015-05-19T13:22:00.000-04:002015-05-19T13:22:30.042-04:00Visual Studio's "Start Without Debugging" option grayed out and F5 doesn't workRan into a very strange situation today. Suddenly, Visual Studio 2015 RC's debug options broke and the F5 key would no longer start the project in debug mode. Even IISExpress had disappeared, only showing "Start", which generated this error when clicked: "The debugger cannot continue running the process. Unable to start debugging."<br />
<br />
Another issue: The References folder was empty, even though .NET 4.5.1 and 5.0 were added earlier.<br />
<br />
I tried a repair via the uninstall utility but issue was still there. Finally, I exported and reset all the settings in Visual Studio following <a href="https://msdn.microsoft.com/en-us/library/ms247075%28v=vs.90%29.aspx" target="_blank">this article</a>. Lo and behold: the options were back and I could run the app in debug or Ctrl-F5 (non-debug mode). Why this happened all of a sudden today, I don't know. I wasn't changing any settings, just editing a C# file when Visual Studio suddenly stopped working.<br />
<br />
Whew!Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-2576039097686958272015-04-23T09:14:00.002-04:002015-04-23T09:17:10.465-04:00Great article on the "Mobilegeddon": Search me: <a href="http://www.infoworld.com/article/2913206/search-engines/search-me-google-mobilegeddon-is-good-news.html" target="_blank">Google's 'Mobilegeddon' is good news</a>. Google has a great <a href="http://googlewebmastercentral.blogspot.com/2015/04/faqs-april-21st-mobile-friendly.html" target="_blank">blog post</a> on it as well.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-22632081118255063652015-04-09T09:51:00.001-04:002015-04-09T09:51:20.498-04:008 Free Online Courses to Grow Your Tech Skills<a href="http://www.cio.com/article/2847396/it-skills/8-free-online-courses-to-grow-your-tech-skills.html" target="_blank">8 Free Online Courses to Grow Your Tech Skills</a>Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0tag:blogger.com,1999:blog-2782359832460307258.post-78974175237473094412015-04-08T17:11:00.004-04:002015-04-08T17:11:48.182-04:00Memory issues with IISExpress process on Visual Studio 2015Visual Studio 2015 comes with IIS Express, which enables the localhost to serve as a web server without having to set up the app in Windows IIS. I was building a C#/MVC/Bootstrap site that kept crashing IIS Express. Some research revealed that we can run the server in 64-bit mode: Just go to Tools > Options > Projects and Solutions > check the box for "Use the 64 bit version of IIS Express for web sites and projects."<br />
<br />
Memory usage by IIS Express went from over 700MB to 8MB now. Much better.Alex Chttp://www.blogger.com/profile/04555184614131343457noreply@blogger.com0