Monday, May 23, 2016

MS SQL - SELECT only words that start with UPPER Case (first letter capitalized)

select top 10 * from [TABLE] WHERE LEFT([Word],1) = UPPER(LEFT([Word],1)) COLLATE Latin1_General_CS_AI


This could also return words that start with a number. I didn't need to care for this case as most words that start with numbers are probably proper names too.



Friday, April 8, 2016

MS VS2015 - Cannot filter columns with null

In Visual Studio 2015 in the sql datatable filter menu, there is no option to filter columns where the value is null. When entering is null into the filter view, the 'is null' is removed.

Steps: Open Visual Studio > Connect via SQL Server Object Explorer > Right click on table > View Data > Click on filter button > select filter field on any column > type "is null" > press enter or click on another field.

Wednesday, March 2, 2016

C# Speed Test - Basic Loops Anomaly

For the longest time, I have been curious about the efficiency of different algorithms. So I built this page to learn some of the basic time duration of simple code like an empty loop, multiple increments, and datetime assignment.

The page developed: http://dlastlee.com/Apps/Tools/CSMetricsIncrementSpeedTest.aspx

Anomaly

While testing, I found an anomaly with one of the speed tests. Looping a variable that increments runs faster than a loop that does nothing (i.e. noop or nop or no operation).

for (int i=0;i<1000000;i++) j++;
vs

for (int i=0;i<1000000;i++) { }

And this is always the case no matter how many times I run the test. I do not have an answer for this except maybe increments is more efficient running through pipelines than NOPs.


Other Findings

Azure server is about 6-7x faster than my laptop where the empty loop ran about 0.015 seconds on Azure vs 0.07 seconds on my laptop. 

DateTime is 20x slower than a simple increment or null.

Declaring a new DateTime is barely slower than declaring a DateTime variable outside the loop. This is more noticeable 

Friday, February 26, 2016

Tuesday, February 23, 2016

Artificial Intelligence - Scripting

I am still looking for a decent scripting language or at least a way to run code on-demand. The purpose is to create an AI that is capable of learning new abilities by calling existing functions. I do not want to create a function to display time. I want to be able to tell the AI to run Console.WriteLine(DateTime.Now.ToString()); which would result in the output of a time.

On a more advanced note, I would create specialized functions to add to the AI's capabilities. For example, create a function to determine if a shape is a triangle. I would then teach the AI that it has that feature and have it execute the function. This would be similar to humans learning to do functions already available to us like jumping to skipping to high jumping like any other complex actions.

But to have the AI start, there must be some basic functions that it needs to be capable of. There is definitely a need to replicate actions. Second, there needs to be a way for it to acknowledge that an action is positive or negative. Third, the AI cannot have the ability to do certain things like kill itself (i.e. delete itself), delete memory, etc.

Currently, the AI is still in its basic steps and still figuring out how to architect the process. The AI can only understand static commands and output pre-programmed responses. There is a second level of topic recognition so that a user can ask a two-stage question, although this is also pre-programmed and even more limited.

The next step is to have the AI access database information. This way it can at least have some basic manufacturing level AI status.


Reference

http://dlastlee.com/dAI/dAI.aspx

Tuesday, February 16, 2016

C# Partial Date Class

I have finally gotten around to creating a partial date class which can handle unknown date parts. The way that I managed this was by having a flag field to manage which parts of the date is unknown. Previously, I had separate fields for each part (i.e. day, month, and year). 

I find this method much easier to manage and cleaner to manipulate the different fields while having the same benefits of multiple fields (except for null values which was not important). On top of that, I only need two fields to manage instead of three fields and still have the flexibility to expand to include times if needed.

The first field is a date column. For unknown parts, any value will suffice. For example, if you knew someone started at the company 10 years ago, that person started in 2006. Without knowing the date and month, I just enter into the system 1/1/2006 (this can be 2/4/2006, 10/29/2006, etc.).

The second field is a flag field to let me know which parts of the date is unknown. I have designated that the column as a binary to minimize the size as I do not really need that many:
1 = day
2 = month
4 = year
8 = decade
16 = century
32 = millennium

If I do not know the day (for example someone's birthday is in March 2016), the date would be 3/1/2016 with a flag of 1. For the company start date example, the date would be 1/1/2006 with a flag of 3. 3 in binary would be 11 designated both day and month.

Unfortunately, I didn't think this completely through so the logic kind of changes for decade, century, and millennium. Here, I use these flags when year is 0 otherwise it overrides the remaining values because unknown year would also mean unknown decade, century, and millennium.

If I had time to redo the logic, the each flag could be used for each digit of the year. For example:
4 = 201X
8 = 20X6
16 = 2X16
32 = X016

The reason I think this is cleaner is because I would have all the flexibility to manipulate the year without losing any benefits of the current method. I have not switched because the flexibility is not great enough for me to update all the data and code because data degradation is consistent from smaller value to larger value. In other words, if the month is unknown, the day is also unknown. It is rare that the day is known without the month. It can happen but I have not had a need for partial years.

Most importantly for the class is the ToString() function. This saves me a lot of time of having to display partial dates. Currently, I just display the missing date as ?? (ie. 02/??/2016, 02/16/????, ??/??/2016, etc.). This could be expanded with more date formats.

Metadata file '....dll' could not be found - Mismatched .NET Version After Adding New Project

I added a new project to my solution and suddenly I get this error:
Metadata file '....dll' could not be found

I spent a few hours troubleshooting this error and was about to pull my hair out when I decided to look at the output tab. This provided more details than just the error above which basically was because my new project was on a newer version of .NET (4.5.2) while the rest of my projects were on (4.5).

To fix this, I just had to go into the project properties and change all the versions (decided to go to 4.6). Voila, simple fix... then I just wanted to bang my head against the wall.

I followed all the steps found searching on google but none of those solutions worked. Those suggested to remove/add references, manual build, clean/rebuild builds, etc. I eventually narrowed it down that it was definitely the new project, but the solution builds if no references point to it. The instant I have a reference even when not using anything in the new project will throw the error.

In conclusion, go to the Output tab to get more details on what the actual issue is.

Sunday, February 7, 2016

ASP.NET Web Services (first impression)

Implementing Microsft Web Services took a lot longer than I expected.  I was determined to use .NET's ScriptManager to implement the web service because I have already done custom javascript with JSON to pull from web services before.

Most frustratingly, I got stuck on the javascript code calling the webservice. Simply, I didn't realize the function takes in one more parameter than the web service requires. For example, I created a webservice "RepeatResponse(string UserInput)" which would mean that the javascript code would be "[namespace].[class].RepeatResponse("blah blah", [functionName]);" where functionName is a javascript function that will run when the web service responds.

For whatever reason, I did not think about it until I almost gave up and started to remove the javascript for ASP.NET's ScriptManager. While considering the pseudo-code in my head, I realized that I needed to execute a function when the web service responds which caused the light bulb to go off.

The other difficulty is troubleshooting the issue. Although I can break within the javascript, there is no error when the function is called. The only response I received was null.

Overall, there were a few other hiccups in fixing the setup of web services in Visual Studio. So far, I think it may have actually been easier to just use a simple JSON function to execute the web service. I have not found any strong evidence of using ScriptManager over regular JSON.


Note:
To implement ScriptManager, web.config also needs to be updated to include the ScriptHandlerFactory.
<system.webServer>
      <handlers>
        <add name="ScriptHandlerFactory" path="*.asmx" verb="*"
             type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
             modules="ManagedPipelineHandler"
             scriptProcessor=""
             resourceType="Unspecified"
             requireAccess="Script"
             allowPathInfo="false"
             preCondition="integratedMode"
             responseBufferLimit="4194304"
             />      
      </handlers>
        <validation validateIntegratedModeConfiguration="false"/>
    </system.webServer>
Reference
https://msdn.microsoft.com/en-us/library/bb763183.aspx - Sample in link does not work

Saturday, January 23, 2016

ASP.NET GridView datastringformat - custom date format

To create custom data format (or any standard string format used by Microsoft):

DataFormatString="{0:MM/dd/yyyy}"


For standard formats:
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring(v=vs.110).aspx


Sample:
http://dlastlee.com/Apps/SWRM/Releases.aspx

Friday, January 22, 2016

C# GridView - Hide Cell/Link When Value is NULL

By default, I could not get GridView to hide hyperlink (HyperLinkField) when the tag value is null. I tried searching for a way to get around this and did not find a simple solution.

First, the solution that I decided to do was just to update my query to provide the text when there is a value and an empty string if the value is null. I do this using a CASE...WHEN...END in my sql query.

For example:
SELECT *, newcolumn = CASE WHEN column IS NULL THEN '' ELSE 'text' END FROM table

In the gridview, I set gridview's DataTextField = newcolumn.

For example:
<asp:HyperLinkField DataNavigateUrlFields="columnid" DataNavigateUrlFormatString="http://www.dlastlee.com/?id={0}" HeaderText="column" DataTextField="newcolumn" />

Another method from what I found was to use an ItemTemplate. http://forums.asp.net/t/1210815.aspx?Conditional+Logic+on+HyperlinkField


For some reason, this was actually very difficult to find. I wonder if I am doing something incorrectly. I couldn't possibly be the only person to want to do this. Everyone seems to want to hide a column.


I used this logic for list of movies that links to other sites:
http://dlastlee.com/Apps/Generic/FilmographyMovies.aspx


Monday, January 11, 2016

HR - Replacement to Resumes?

The resume was a method to transfer the knowledge of a person's skillsets to the company. With today's technology to easily store all skillsets into a central location, I believe companies should have a method to determine which skillsets to review instead of depending on candidates to "highlight" the skills that they think is what the company is looking for.

It is great skill to be able to market oneself in 1-2 pages, but like marketing there are hidden variables that may make a difference. Why would a company hire someone because they know how to market themselves? And then compensate the candidate accordingly? What can end up is someone being compensated not according to skillsets or personal situations, thus causing more dissatisfaction within the group.

That is the industry standard. I believe there is room for companies that can make use of modern technology to filter actual skillsets that give better gauge on an employees potential fit to the company. Happy employer, happy employee would make a more cost effective benefit to both parties.

There should be patterns to a person like they have for personalities (16personalities.com). Basically a corporate HR should be able to see current skillsets and potential future growths. Reality is that people are not looking to change to do the same thing, so to poach star employees for lower cost is to move them to a new position.

In conclusion, the whole process to have candidates sell themselves then have corporations pick the best sales pitch seems quite backwards. Corporations have the dataset on what types of skillsets make a good candidate. Candidates are more valuable when they can focus on what they do well and not waste some talents on self-marketing or understanding their value in the market. Bridging this gap would be a win-win for bother employer and employee.


Saturday, January 9, 2016

HR - Years of Experience

I have never understood the whole "X-Y years of experience" because this seems to be a metric that does not mean anything and nearly impossible to gauge. I have worked with people with 20+ years of experience yet struggle with the basics. If anything, I have more concerns that someone has been doing the same thing for 20+ years especially in the technology industry. There are some exceptions like chefs, service providers, etc. But even then, that is not a strong indication of knowledge or skill.

In my experience, I find that the more "experienced" colleagues to be much slower at completing tasks and quite inflexible in learning new ideas. Maybe I pick things up faster. I end up wasting a lot of time just waiting getting trained or training others. On top of that, they seem to get flustered and stressed over changes making improvements ever harder to adopt. Although, I have found that these types of colleagues usually have decent work ethics.

On the other hand, those who appear to be less experienced have many variables that make them hard to determine what quality of work is expected. Work ethic is very difficult to judge within a couple hours but easily seen after a month. Learning curve is also another large variable. 

What if someone is experienced but has short exposure to new skill? What does it even mean to have 2 years of experience? I worked at a small business where I had to work on many things at the same time. I could claim 20 different skills at 2 years, but I will not be as good as someone who does one thing for 2 years. On paper, I would look better and other person could be filtered even if I am deemed unfit after an interview. 

So at the end of the day, what does "years of experience" even say about a candidate? I've worked jobs where they requested 5-10 years yet I learn most of it within a few months and excel my colleagues within a year. I think this description is such a waste of space while misleading everyone.

As a candidate, this shows me the HR has no idea what the position entails. This is a way to summarize the job description without knowing what they are looking for, yet a method to make it look like they did some research because nothing looks better than numbers. And sadly, knowledgeable candidates know how to game the system.

My goal with the Human Resource Management application is to better understand the roles and candidates. I believe good companies need a better method to hire quality candidates and for good candidates to find good companies, so there must be a method to bridge this gap.


As of 1/9/2016, there has been little development. The database is still being constructed and most of my attention is still on the other applications.