Skip to content

Instantly share code, notes, and snippets.

View NaserKhoshfetrat's full-sized avatar

Naser Khoshfetrat NaserKhoshfetrat

View GitHub Profile
# Monthly CSV Combiner
Write-Host "Monthly CSV Combiner" -ForegroundColor Cyan
# -------------------- FUNCTION DEFINITIONS --------------------
function New-OutputFolder {
<#
.SYNOPSIS
Creates the output folder if it doesn't exist
#>
@NaserKhoshfetrat
NaserKhoshfetrat / Google sheet Apps Script.gs
Last active December 7, 2025 06:45
Converts Gregorian date to Persian date
function G2J(gDates) {
// Handle arrays and single values
if (Array.isArray(gDates)) {
return gDates.map(row => row.map(cell => convertToJalaliSafe(cell)));
}
return convertToJalaliSafe(gDates);
}
function convertToJalaliSafe(gDate) {
// Normalize input to a JS Date
#login as superuser into postgres super user
.\psql.exe -u postgres
#show all database
\l
#change the current database to the one that you want to show tables:
\c testDb
# command from the PostgreSQL command prompt to show tables in the selected database:
#check sign version v1 and v2
java -jar .\apksigner.jar verify --verbose --print-certs .\test-app.apk
#check sign version v1, v2, v3, v4 which set by enableV3Signing, enableV4Signing
java -jar .\apksigner.jar verify -v -v4-signature-file .\test-app.apk.idsig .\test-app.apk
@NaserKhoshfetrat
NaserKhoshfetrat / linux.sh
Last active January 7, 2023 12:15
linux command sheet
#######################################################################################################
##os-centos-7##
#get centos version
$cat /etc/centos-release
#get system info
$hostnamectl
#get kernel
@NaserKhoshfetrat
NaserKhoshfetrat / snippet.sql
Created September 14, 2022 15:43
sqlserver snippet
SWITCHOFFSET(CONVERT(datetimeoffset, [CreatedAt]), DATENAME(TzOffset, SYSDATETIMEOFFSET()))
git clean -xdf --dry-run //to remove absolutely every file on the .gitignore list
dotnet new gitignore //touch .gitignore
@NaserKhoshfetrat
NaserKhoshfetrat / performance.sql
Created June 10, 2022 11:17
sql server procedure performance
-- sys.dm_os_performance_counters is a system Dynamic Management View (DMV) that returns one row for each SQL Server performance counter. It's useful for obtaining information about current performance counter values.
declare @cntr_value bigint
Select @cntr_value=cntr_value
from sys.dm_os_performance_counters
where instance_name='Fabrics' and
counter_name='Write Transactions/sec'
waitfor delay '00:00:01'
Select cntr_value -@cntr_value
@NaserKhoshfetrat
NaserKhoshfetrat / TableSpaceUsed.sql
Last active June 10, 2022 10:05
sql server procedure TableSpaceUsed
--<sys.sp_MSforeachtable>: execute sp_spaceused for all of database table
--<sp_spaceused>: return rows, index size and data size of table
EXEC sys.sp_MSforeachtable 'sp_spaceused ''?''';
--or as table
USE [Fabrics]
GO
CREATE TABLE #TableSpaceUsed(
[name] [nvarchar](120) NULL,
[rows] [nvarchar](120) NULL,
@NaserKhoshfetrat
NaserKhoshfetrat / fabrics.sql
Created June 9, 2022 07:34
sqlserver dummy database
-- Fabrics V1.2
-- Creating a SQL database from scratch
USE Fabrics
GO
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[usp_Fabrics]') AND type in (N'P', N'PC'))
DROP PROCEDURE usp_Fabrics
GO
CREATE PROCEDURE [dbo].usp_Fabrics
(@CreateClients INT = 2500,
@CreateOrders INT = 5000)