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 / ThemeContext.js
Last active July 20, 2023 09:32
Theme Change ReactJS provider
import { createContext, useState } from 'react';
const ThemeContext = createContext()
const ThemeProvider = function({ children }) {
// children are subscribers
const [theme, setTheme] = useState("light");
const toggleTheme = function() {
setTheme((preTheme) => {
@deepanshumehtaa
deepanshumehtaa / docdocker-compose.dev.yaml
Created August 28, 2023 15:46
docker compose and Docker File : Django on container and SQL locally
# Docker Compose, a tool for defining and running multi-container Docker applications.
# Commands to Run
# docker-compose -f ./docker-compose.dev.yaml build
# docker-compose -f ./docker-compose.dev.yaml up -d
# docker-compose exec web python manage.py migrate --noinput
version: "3.9"
services:
@deepanshumehtaa
deepanshumehtaa / docker-compose.prod.yaml
Last active August 28, 2023 18:55
docker compose django redis and mysql
# Commands to Run
# docker-compose -f ./docker-compose.prod.yaml build
# docker-compose -f ./docker-compose.prod.yaml up -d
# docker-compose -f ./docker-compose.prod.yaml exec web python manage.py migrate --noinput
# docker-compose -f ./docker-compose.prod.yaml exec web python manage.py createsuperuser
version: "3.9"
services:
@deepanshumehtaa
deepanshumehtaa / docker-compose.yaml
Created August 28, 2023 19:22
Docker compose RabbitMq
version: "3.9"
services:
# pull and start rabbitmq container
rabbitmq:
image: rabbitmq
command: rabbitmq-server
expose:
- "5672:5672" #amqp
@deepanshumehtaa
deepanshumehtaa / CountDownSolution.jsx
Last active July 31, 2024 11:03
React CountDown Timer
import React, { Fragment } from 'react';
import { useState, useEffect } from 'react';
export default function Solution() {
const [totalSeconds, setTotalSeconds] = useState(0);
const [isPaused, setPaused] = useState(true); // Start with paused state
const [time_str, setTime_str] = useState("00:00");
function MyStart() {
let seconds = parseInt(document.getElementById("secs").value);
@deepanshumehtaa
deepanshumehtaa / main.go
Last active October 1, 2023 14:31
Simple Gin App
/*
create `go.mod` (requirements.txt of go):
> go mod init myApp/web-service-gin
then run
> go get github.com/gin-gonic/gin
> github.com/thoas/go-funk
create `main.go`
// go run main.go
// create a static folder and create `static.html`
package main
import (
"fmt"
"log"
"net/http"
)
@deepanshumehtaa
deepanshumehtaa / main.go
Created October 8, 2023 12:18
Go-mux-server
// go run .
package main
import (
"encoding/json"
"fmt"
"log"
"math/rand"
"net/http"
@deepanshumehtaa
deepanshumehtaa / MyScrapy.py
Last active March 1, 2024 04:27
Scrapy boilerPlate
import re
import scrapy
from scrapy.http import Request, Response
class MyscraperSpider(scrapy.Spider):
"""
> scrapy runspider MyScraper.py -o quotes.jsonl
"""
// npm install axios
import axios from 'axios';
import { useEffect, useState } from 'react';
export default function StudentDataCompoenet(){
const [data, setData] = useState([]);