Skip to content

Instantly share code, notes, and snippets.

View mystikraz's full-sized avatar

Raj Tandukar mystikraz

View GitHub Profile
@mystikraz
mystikraz / dockerComaands
Last active March 17, 2024 07:04
dockerComaands
docker build .
docker build -t blog/posts .
docker run [image id or image tag]
docker run -it [image id or image tag][cmd] eg. sh
docker ps
docker exec -it [container id][cmd]
docker logs [container id]
docker stop my_container
sudo systemctl stop docker
@mystikraz
mystikraz / conditionalprops
Created July 9, 2023 07:13
props optional compulsory
type Props={
name:string
} & (MaleProps | FemaleProps)
type MaleProps={
gender:'male'
salary:number
}
type FemaleProps={
@mystikraz
mystikraz / gist:cd7ea37886fd76ece387596447bdbb45
Created April 6, 2023 03:35
check sql server database size
EXEC sp_spaceused
@mystikraz
mystikraz / gist:14872c086a8165c793b83bb5b250e065
Last active February 28, 2023 04:46
Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
exec sp_updatestats
public class ApplicationDbContext : DbContext
{
public ApplicationDbContext()
{
Database.SetCommandTimeout(150000);
}
}
@mystikraz
mystikraz / gist:023e6ee51d7b28d29d5e71b52e5a0f8e
Created November 10, 2022 07:26
Edit Remote git commit
git reset --soft HEAD~3
git commit -m "New message for the combined commit"
git push -f origin MyBranch
@mystikraz
mystikraz / gist:cae445230271f6875e375aecbd5f438b
Created July 29, 2022 03:19
Pagination in stored procedure
DECLARE @PageNumber AS INT
DECLARE @RowsOfPage AS INT
DECLARE @SortingCol AS VARCHAR(100) ='FruitName'
DECLARE @SortType AS VARCHAR(100) = 'DESC'
SET @PageNumber=1
SET @RowsOfPage=4
SELECT FruitName,Price FROM SampleFruits
ORDER BY
CASE WHEN @SortingCol = 'Price' AND @SortType ='ASC' THEN Price END ,
CASE WHEN @SortingCol = 'Price' AND @SortType ='DESC' THEN Price END DESC,
@mystikraz
mystikraz / gist:e7e13410efaef33896cde866657dfbf0
Created June 14, 2022 06:31
Autofac dependency resolver in static class
DependencyResolver.Current.GetService<IFeatureFlagService>();
@mystikraz
mystikraz / gist:6317b6d3c23f6986bcf233fd500ef05b
Created March 13, 2022 10:49
download files, csv, pdf, excel, zip files using ajax javascript, jquery
async function getZipAsync(form) {
let response = await fetch("/BuyerReport/NewCharges" + '?' + (new URLSearchParams($(form).serialize())).toString());
let res = await response.blob();
if (res.type === 'application/zip') {
const downloadUrl = window.URL.createObjectURL(res);
const link = document.createElement('a');
link.setAttribute('href', downloadUrl);
link.setAttribute('download', 'new charges report');
link.style.display = 'none';
document.body.appendChild(link);
//arranging groupBy deviceId and Qty
var result = [];
cartItems.reduce(function (res, value) {
if (!res[value.deviceId]) {
res[value.deviceId] = { deviceId: value.deviceId, qty: 0 };
result.push(res[value.deviceId])
}
res[value.deviceId].qty += value.qty;
@mystikraz
mystikraz / referencesListMysql
Created September 21, 2021 05:09
list all references of a table in Mysql
SELECT
ku.CONSTRAINT_NAME AS "Foreign key",
-- CONCAT("`", ku.TABLE_SCHEMA, "`.`", ku.TABLE_NAME, "`") AS "In",
ku.TABLE_NAME AS "In",
GROUP_CONCAT(ku.COLUMN_NAME) AS "Source column",
CONCAT("`", ku.REFERENCED_TABLE_SCHEMA, "`.`", ku.REFERENCED_TABLE_NAME, "`") AS "References",
GROUP_CONCAT(ku.REFERENCED_COLUMN_NAME) AS "Target column"
FROM information_schema.KEY_COLUMN_USAGE AS ku
WHERE ku.REFERENCED_TABLE_SCHEMA = 'dev.bidenergy.com'
AND ku.REFERENCED_TABLE_NAME = 'site'