Friday, August 30, 2019

Are table names in MySQL case sensitive?




Are table names in MySQL case sensitive?



On my Windows dev machine the code I have is able to query my tables which appear to be all lowercase. When I deploy to the test server in our datacenter the table names appear to start with an uppercase letter.



The servers we use are all on Ubuntu.


Answer



In General:



Database and table names are not case sensitive in Windows, and case sensitive in most varieties of Unix.





In MySQL, databases correspond to directories within the data
directory. Each table within a database corresponds to at least one
file within the database directory. Consequently, the case sensitivity of the
underlying operating system plays a part in the case sensitivity of
database and table names.




One can configure how tables names are stored on the disk using the system variable lower_case_table_names. (in my.cnf configuration under [mysqld])




Read the section: 10.2.2 Identifier Case Sensitivity for more information.


multiple monitors - ATI HD5700 with HDMI, DVA and VGA & 3 displays

I have a ATI HD5700 graphics card with HDMI (could be DisplayPort too?), DVI and VGA outputs and I want to use three monitors. Currently I have one monitor working with HDMI and other one working with DVI but if I plug the third monitor to VGA, it does not work without first disabling one of the two other monitors in the ATI Catalyst Center.


How can I get the three monitors working together?

jvm - How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version



I am trying to use Notepad++ as my all-in-one tool edit, run, compile, etc.



I have JRE installed, and I have setup my path variable to the .../bin directory.




When I run my "Hello world" in Notepad++, I get this message:



java.lang.UnsupportedClassVersionError: test_hello_world :
Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
.........................................



I think the problem here is about versions; some versions of Java may be old or too new.




  1. How do I fix it?

  2. Should I install the JDK, and setup my path variable to the JDK instead of JRE?

  3. What is the difference between the PATH variable in JRE or JDK?


Answer



The version number shown describes the version of the JRE the class file is compatible with.




The reported major numbers are:



Java SE 13 = 57,
Java SE 12 = 56,
Java SE 11 = 55,
Java SE 10 = 54,
Java SE 9 = 53,
Java SE 8 = 52,
Java SE 7 = 51,
Java SE 6.0 = 50,

Java SE 5.0 = 49,
JDK 1.4 = 48,
JDK 1.3 = 47,
JDK 1.2 = 46,
JDK 1.1 = 45


(Source: Wikipedia)



To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.




For example, in order to generate class files compatible with Java 1.4, use the following command line:



javac -target 1.4 HelloWorld.java


With newer versions of the Java compiler you are likely to get a warning about the bootstrap class path not being set. More information about this error is available in a blog post New javac warning for setting an older source without bootclasspath.


javascript - Loop inside React JSX

There are many solutions posted out there interms of iterating an array and generating jsx elements. All of them are good but all of them used index directly in loop. We are recommended to use unique id from data as a key but when we do not have unique id from each object in the array we will use index as a key but you are not recommended to use index as a key directly.



One more thing why we go for .map but why not .foEach because .map returns an new array. There are different ways of doing .map these days.



Below different version of using .map illustrates in detail about how to use unique key and how to use .map for looping jsx elements



.map without return when returning single jsx element and unique id from data as a key version



const {objects} = this.state;



{objects.map(object => )}



.map without return when returning multiple jsx elements and unique id from data as a key version



const {objects} = this.state;



{objects.map(object => (



))}



.map without return when returning single jsx element and index as a key version




const {objects} = this.state;


{objects.map((object, index) => )}



.map without return when returning multiple jsx elements and index as a key version



const {objects} = this.state;



{objects.map((object, index) => (



))}




.map with return when returning multiple jsx elements and index as a key version



const {objects} = this.state;


{objects.map((object, index) => {
return (




)
})}



.map with return when returning multiple jsx elements and unique id from data as a key version



const {objects} = this.state;



{objects.map(object => {
return (



)
})}




The other way is



render(){
const {objects} = this.state;
const objectItems = objects.map(object => {
return (



)

})
return(


{objectItems}


)
}

c# - How to get short value using Double Function?











my double function generating values like this



  56,365989365



i want just value like this 56,36
how to get this ?


Answer



Use Math.Round. The second argument is the number of places.



var x = Math.Round(56.365989365, 2);

c# - Error when using UserPrinciple on a remote machine

So I have a hosting domain that's currently running my App on IIS 7, Application Pool Settings:





  • Identity: Network Service

  • Managed Pipeline Mode: Integrated

  • .NET Version: v4.0

  • Name: .NET v4.5



IIS Authentication settings:




  • Anonymous: Disabled


  • Impersonation: Enabled

  • Forms: Disabled

  • Windows: Enabled



There is also a different version of the app that is working fine with these settings. So within my current App I have this code to get and store the user SID:



public static SecurityIdentifier GenerateUserSID()
{
return (UserPrincipal.Current.Sid);

}

public virtual ActionResult AddComment (string comment, int taskId, DateTime selectedDate)
{
var msg = string.Empty;

try
{
Comment newComment = new Comment();


var sid = ApplicationUtils.GenerateUserSID();

newComment.CommentText = comment;
newComment.Analyst = sid.ToString();
newComment.TaskHistoryId = taskId;
newComment.SelectedDateTimestamp = selectedDate;
newComment.AddedTimestamp = DateTime.Now;

_db.Comments.Add(newComment);
_db.SaveChanges();

}
catch (Exception e)
{
msg = "Error: " + e;

return Json(msg, JsonRequestBehavior.AllowGet);
}

return Json(comment, JsonRequestBehavior.AllowGet);
}



And I get the following error returned:




System.DirectoryServices.DirectoryServicesCOMException (0x80072020): An operations error occurred. at System.DirectoryServices.DirectoryEntry.Bind(Boolean throwIfFail) at System.DirectoryServices.DirectoryEntry.Bind() at System.DirectoryServices.DirectoryEntry.get_AdsObject() at System.DirectoryServices.PropertyValueCollection.PopulateList() at System.DirectoryServices.PropertyValueCollection..ctor(DirectoryEntry entry, String propertyName) at System.DirectoryServices.PropertyCollection.get_Item(String propertyName) at System.DirectoryServices.AccountManagement.PrincipalContext.DoLDAPDirectoryInitNoContainer() at System.DirectoryServices.AccountManagement.PrincipalContext.DoDomainInit() at System.DirectoryServices.AccountManagement.PrincipalContext.Initialize() at System.DirectoryServices.AccountManagement.PrincipalContext.get_QueryCtx() at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithTypeHelper(PrincipalContext context, Type principalType, Nullable`1 identityType, String identityValue, DateTime refDate) at System.DirectoryServices.AccountManagement.Principal.FindByIdentityWithType(PrincipalContext context, Type principalType, IdentityType identityType, String identityValue) at System.DirectoryServices.AccountManagement.UserPrincipal.FindByIdentity(PrincipalContext context, IdentityType identityType, String identityValue) at System.DirectoryServices.AccountManagement.UserPrincipal.get_Current() at Governance.Controllers.DashboardController.AddComment(String comment, Int32 taskId, DateTime selectedDate)




This only happens when accessing the App on remote machines, on the local machine it works fine.




Does anyone know what's causing this and how to fix it?

Which, if any, C++ compilers do tail-recursion optimization?



It seems to me that it would work perfectly well to do tail-recursion optimization in both C and C++, yet while debugging I never seem to see a frame stack that indicates this optimization. That is kind of good, because the stack tells me how deep the recursion is. However, the optimization would be kind of nice as well.



Do any C++ compilers do this optimization? Why? Why not?




How do I go about telling the compiler to do it?




  • For MSVC: /O2 or /Ox

  • For GCC: -O2 or -O3



How about checking if the compiler has done this in a certain case?





  • For MSVC, enable PDB output to be able to trace the code, then inspect the code

  • For GCC..?



I'd still take suggestions for how to determine if a certain function is optimized like this by the compiler (even though I find it reassuring that Konrad tells me to assume it)



It is always possible to check if the compiler does this at all by making an infinite recursion and checking if it results in an infinite loop or a (I did this with GCC and found out that -O2 is sufficient), but I want to be able to check a certain function that I know will terminate anyway. I'd love to have an easy way of checking this :)







After some testing, I discovered that destructors ruin the possibility of making this optimization. It can sometimes be worth it to change the scoping of certain variables and temporaries to make sure they go out of scope before the return-statement starts.



If any destructor needs to be run after the tail-call, the tail-call optimization can not be done.


Answer



All current mainstream compilers perform tail call optimisation fairly well (and have done for more than a decade), even for mutually recursive calls such as:



int bar(int, int);

int foo(int n, int acc) {

return (n == 0) ? acc : bar(n - 1, acc + 2);
}

int bar(int n, int acc) {
return (n == 0) ? acc : foo(n - 1, acc + 1);
}


Letting the compiler do the optimisation is straightforward: Just switch on optimisation for speed:





  • For MSVC, use /O2 or /Ox.

  • For GCC, Clang and ICC, use -O3



An easy way to check if the compiler did the optimisation is to perform a call that would otherwise result in a — or looking at the assembly output.



As an interesting historical note, tail call optimisation for C was added to the GCC in the course of a diploma thesis by Mark Probst. The thesis describes some interesting caveats in the implementation. It's worth reading.


hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...