Posts

Stored procedure for SQL Server that provides information related to system, memory, CPU, and expensive queries

Stored procedure for SQL Server that provides information related to system, memory, CPU, and expensive queries: CREATE PROCEDURE sp_db_info AS BEGIN -- Get system information SELECT @@SERVERNAME AS "Server Name", @@VERSION AS "SQL Server Version", SERVERPROPERTY('Edition') AS "Edition", SERVERPROPERTY('ProductLevel') AS "Product Level", SERVERPROPERTY('ProductUpdateLevel') AS "Product Update Level", SERVERPROPERTY('ProcessID') AS "Process ID", SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS "Computer Name" -- Get memory information SELECT (physical_memory_in_use_kb / 1024) AS "Memory Used (MB)", (available_physical_memory_kb / 1024) AS "Memory Available (MB)" FROM sys.dm_os_sys_memory -- Get CPU information SELECT cpu_count AS "CPU Count", hyperthread_ratio AS "Hyperthread Ratio", cpu_ticks/(cpu_ticks/ms_ticks) AS "CPU Usage (%)...

Gratuity calculation

 Gratuity is calculated based on the number of years an employee has worked with an organization and their last drawn salary. In India, the gratuity amount is calculated using the following formula: Gratuity = (Last drawn salary x 15 x Number of years worked) / 26 Where, Last drawn salary: the basic salary plus dearness allowance (if applicable) of the employee at the time of leaving the job. 15: represents the number of days in a month 26: represents the number of working days in a month Assuming that the employee has completed 5 years of continuous service, and their last drawn salary was Rs. 12 lakh per annum, their gratuity amount would be: Gratuity = (12,00,000 x 15 x 5) / 26 Gratuity = Rs. 13,84,615.38 Therefore, the gratuity amount for this employee after 5 years of service would be Rs. 13,84,615.38. If the salary of the employee was Rs. 20,000 per month in the 4th year and Rs. 60,000 per month in the 5th year, then the gratuity amount would be calculated as follows: Average...

Deep understanding of object-oriented programming concepts, including polymorphism and static classes

C# Static Class Explanation. A problem that can be solved using a static class : Suppose you are developing a utility library for a company that needs to perform some mathematical calculations frequently in their application. The company has specified that these calculations need to be performed as quickly as possible and without any additional overhead. They have also requested that the calculations be made available in a way that does not require creating an instance of a class. How would you approach solving this problem? How might a static class be useful in this scenario? Solution    To solve this problem, we can create a static class that contains the mathematical calculation methods that the company needs to perform frequently. Since a static class can be accessed without creating an instance of the class, it satisfies the requirement that the calculations should be available without any additional overhead. Here is an example implementation: public static class MathUti...

Adapter structural design pattern

 A design pattern is a general solution to a recurring problem in software design. It is a proven approach to solving a specific type of problem that arises frequently in software development. Design patterns provide a shared vocabulary and a set of well-defined steps for solving common problems, making them a valuable tool for software engineers to use when building applications. Adapter Pattern - It allows the interface of an existing class to be used by another interface. // The Target interface specifies the client's required interface. interface ITarget { void Request(); } // The Adaptee contains some useful behavior, but its interface is incompatible with the existing client code. class Adaptee {     public void SpecificRequest()     {         Console.WriteLine("Adaptee specific request.");     } } // The Adapter makes the Adaptee's interface compatible with the Target's interface. class Adapter : ITarget {     pri...

Replace word using dictionary Program

Replace word using dictionary Program  to replace word using dictionary javascript Here is an example of a program in JavaScript that replaces a word in a string using a dictionary:   const dictionary = { "{NANE}": "Jhon", "{DESIGNATION}": "Software Engineer", };  const replaceWord = (sentence, dictionary) =>  {   let newSentence = sentence;  for (let key in dictionary) {       newSentence = newSentence.replace(key, dictionary[key]);  }  return newSentence;  };  const sentence = "My name is {NAME} and I am {DESIGNATION}";  console.log(replaceWord(sentence, dictionary));  // Output: "My name is John and I am SoftwareEngineer. "  In this example, the dictionary object contains key-value pairs of words to be replaced and their replacements. The replaceWord function takes a sentence and the dictionary as input, and loops through the keys in the dictionary. For each key, it replaces all occurrences...

change the pitch of an audio file using ffmpeg

  Change Audio Pitch FFmpeg Change audio pitch ffmpeg To change the pitch of an audio file using ffmpeg, you can use the "asetrate" filter. For example, to increase the pitch by one octave (double the frequency), you can use the following command: ffmpeg -i input.mp3 -filter:a "asetrate=2*44100" output.mp3 An octave is a musical interval that spans 12 semitones on a standard piano keyboard. Doubling the frequency of a note results in an increase in pitch by one octave. A semitone is the smallest musical interval commonly used in Western tonal music, and it is equal to the interval between two adjacent notes on a piano or other musical keyboard. It is also known as a half step or a half tone. For example, the interval between C and C# is a semitone. In Western music, there are 12 semitones in an octave, which is the interval between two notes that have the same letter name but are separated by an interval of 12 pitch classes. To decrease the pitch by one octave (half...

Convert Json to Table

Image
 Convert Json to Table click below to open converter Json to Table Tip : open console of browser. Right click and click on inspect or F12 to open the console  Use JSON.stringify method to convert Object to Json String Now copy the json string and Past it to Json to Table and click on convert  This will help to prevent Json Invalid data error. eg: var users = [     {         id: 1,         name: 'bruce'     },     {         id: 2,         name: 'peter'     } ] JSON.stringify(users) ' [{"id":1,"name":"bruce"},{"id":2,"name":"peter"}] '