Skip to content

Instantly share code, notes, and snippets.

View deepanshumehtaa's full-sized avatar
💭
If Good things are not coming to you, Snatch them™

Deepanshu mehta deepanshumehtaa

💭
If Good things are not coming to you, Snatch them™
View GitHub Profile
@deepanshumehtaa
deepanshumehtaa / sqlalchemy.py
Last active March 14, 2024 14:06
sqlalchemy
https://chat.openai.com/share/3f1472a2-ff59-4b88-bec4-36c75421e3ed
"""
from sqlalchemy import (
Column, BigInteger, Integer, String, Text, ForeignKey, Uuid, Enum, DateTime, CheckConstraint,
)
from sqlalchemy import func, select
from sqlalchemy.sql.expression import (
case as sql_case,
cast as sql_cast,
@deepanshumehtaa
deepanshumehtaa / React Js Practice.js
Last active March 15, 2024 14:39
React Js Practice
TWO Rules for writing component function in ReactJS:
1. should start with Upper case char
2. should return that could be render on the screen
ex:
"""
from MyComp import "./App.jsx";
export default function MyReducerComp(){
const [count, dispatchCount] = useReducer(reducerFunc, 0);
@deepanshumehtaa
deepanshumehtaa / SQL Tricks Sub Query & CTE.sql
Last active March 18, 2024 14:21
SQL Tricks Sub Query & CTE
https://console.clever-cloud.com/users/me/addons/addon_1315c43c-935c-4889-b9ab-1c64f93bcf61
Database@123
SQL execution:
FROM --> WHERE --> GROUP BY --> HAVING --> SELECT --> ORDER BY
1. WITH also known as a Common Table Expression (CTE):
> powerful tool for simplifying complex SQL queries and improving query readability.
WITH cte_name (column1, column2, ...) AS (
@deepanshumehtaa
deepanshumehtaa / SQL Tricks WINDOWS.sql
Last active March 18, 2024 04:58
SQL Tricks. WINDOWS
> Subtract two months from a date, then return the new date
SELECT DATEADD(month, -2, '2017/08/25') AS DateAdd;
> https://www.w3schools.com/sql/func_sqlserver_dateadd.asp
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
CASE
WHEN condition1 THEN result1
WHEN condition2 THEN result2
...
ELSE result
END
@deepanshumehtaa
deepanshumehtaa / SQL Tricks - joins & LeetCode.sql
Last active September 8, 2024 08:44
SQL Tricks - joins & LeetCode
Self-Join:
1. https://leetcode.com/problems/rising-temperature/
ANS:
SELECT w1.id
FROM Weather w1
JOIN Weather w2
ON DATEDIFF(w1.recordDate, w2.recordDate) = 1
WHERE w1.temperature > w2.temperature;
@deepanshumehtaa
deepanshumehtaa / basic Reader and Builder.java
Last active April 14, 2024 08:11
basic Reader and Builder JAVA
InputStreamReader..............................................................................
- InputStream: class that reads binary data in the form of bytes from a source.
- InputStreamReader: It reads bytes using the given InputStream and then converts them into chars
based on a certain Charset (UTF-8, UTF-16).
- has a read() method that reads a single character (bytes --> characters)
remember:
InputStreamReader.read() != InputStream.read()
1. InputStreamReader reader = new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8)
@deepanshumehtaa
deepanshumehtaa / bare fastApi server.py
Last active April 14, 2024 11:35
bare fastApi server
# uvicorn main:app --reload
# venv\Scripts\activate
from fastapi import FastAPI, Body
from pydantic import BaseModel
app = FastAPI()
@app.get("/")
@deepanshumehtaa
deepanshumehtaa / APIClient.Java
Last active April 14, 2024 12:20
APIClient Java
package org.example.ApiC;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
//import org.slf4j.Logger;
import java.util.Objects;
import okhttp3.MediaType;
@deepanshumehtaa
deepanshumehtaa / application.properties
Last active April 21, 2024 13:51
application.properties
spring.application.name=springPractice0
server.port=8083
jwt.secret=mySecretKey123
# import org.springframework.beans.factory.annotation.Value;
# @Value("${jwt.secret}")
# private String jwtSecret;
# [email protected]@
@deepanshumehtaa
deepanshumehtaa / java API.java
Last active April 19, 2024 07:16
java API.java
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.databind.json.JsonMapper;