Skip to content

Instantly share code, notes, and snippets.

View r1d3rzz's full-sized avatar
💻
Working from home

MyintThwayKhine r1d3rzz

💻
Working from home
View GitHub Profile
@r1d3rzz
r1d3rzz / fileTypeFilter.js
Created June 24, 2024 05:34
File Type Filter WIth JS
function checkFileExtension(file, ...allowFileTypes) {
const allowedExtensions = allowFileTypes; // List allowed extensions
const fileExtension = file.name.split('.').pop().toLowerCase();
return allowedExtensions.includes(fileExtension);
}
function checkContentType(file) {
const allowedTypes = ['image/jpeg', 'image/png', 'application/zip', 'application/pdf']; // List allowed MIME types
return allowedTypes.includes(file.type);
}
@r1d3rzz
r1d3rzz / Get PreviousStartDateAndEndDate.sql
Created July 3, 2024 07:44
Get Previous StartDate And EndDate
DECLARE @CurrentDate DATE = GETDATE();
DECLARE @FirstDayOfPreviousMonth DATE;
DECLARE @LastDayOfPreviousMonth DATE;
-- Calculate the first day of the previous month
SET @FirstDayOfPreviousMonth = DATEADD(MONTH, DATEDIFF(MONTH, 0, @CurrentDate) - 1, 0);
-- Calculate the last day of the previous month
SET @LastDayOfPreviousMonth = EOMONTH(DATEADD(MONTH, -1, @CurrentDate));
BULK INSERT [dbo].[Designations]
FROM 'C:\Users\User\Desktop\Designation.csv'
WITH (
FIELDTERMINATOR = ',',
ROWTERMINATOR = '\n',
FIRSTROW = 2
);
// Assuming employee.PermanentEndDate is DateTime? (nullable DateTime)
if (employee.PermanentEndDate.HasValue)
{
var empPermanentEndDate = employee.PermanentEndDate.Value.Date; // Use .Date to ignore the time part
var today = DateTime.Today;
var previousDay = DateTime.Today.AddDays(-1);
if (empPermanentEndDate == previousDay && previousDay == today)
{
// Do something if empPermanentEndDate is the same as yesterday and today
use HRMS
go
update Employees set Department_Branch_Id = Departments.Department_Id
from Departments
WHERE Departments.Name = Employees.DepartmentName
DTExec.exe /file "D:\filepath" /de "something"
@r1d3rzz
r1d3rzz / gist:1f062f75d37c689ee8bc3923461b4812
Created September 18, 2024 06:34
config for datatable file export
$.extend(true, $.fn.dataTable.defaults, {
processing: true,
responsive: true,
mark: true,
order: [[0, "desc"]],
iDisplayLength: 5,
aLengthMenu: [[5, 10, 25, 50, -1], [5, 10, 25, 50, "All"]],
layout: {
topStart: {
buttons: [
@r1d3rzz
r1d3rzz / gist:895f9ae551c4e809a8a17455d5d8dbf5
Created September 26, 2024 03:46
fix audit log in ssms
SELECT DATEADD(MINUTE, DATEDIFF(MINUTE, GETUTCDATE(), CURRENT_TIMESTAMP), event_time) AS event_time_afterconvert,
getdate() 'Current_system_time'
,statement --for reason
,*
FROM fn_get_audit_file('D:\code\SSMS\Audit\*', DEFAULT, DEFAULT) WHERE action_id = 'LGIF' -- LGIF mean Login Fail
SELECT
s.session_id,
s.login_name,
s.host_name,
s.status,
s.last_request_start_time,
s.last_request_end_time,
r.cpu_time,
r.total_elapsed_time,
r.reads,
@r1d3rzz
r1d3rzz / calInterestRate.sql
Created November 6, 2024 07:28
Calculate Interest Rate SQL
PRINCIPAL_AMOUNT*(INTEREST_RATE/100)/INT_BASIS*TERM