Skip to content

Instantly share code, notes, and snippets.

@sagarPakhrin
sagarPakhrin / events.py
Last active October 16, 2023 20:51
future events list
import pymysql
import requests
from datetime import datetime, timedelta
# Function to send a POST request for scheduling a notification
def send_notification(event_date, event_id, notification_type):
# Adjust the URL and payload as per your Firebase or push notification service
print(f"Event scheduled for: {event_date}")
url = 'https://your-firebase-url.com/schedule-notification'
payload = {
import { INestApplication, Injectable, OnModuleInit } from '@nestjs/common';
import { PrismaClient } from '@prisma/client';
@Injectable()
export class PrismaService extends PrismaClient
implements OnModuleInit {
async onModuleInit() {
await this.$connect();
}

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@sagarPakhrin
sagarPakhrin / package.json
Created March 7, 2021 16:22
For Formik Demo Video
{
// ...
"scripts": {
"start": "craco start",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject"
},
}
// craco.config.js
module.exports = {
style: {
postcss: {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
],
},
},
@sagarPakhrin
sagarPakhrin / CustomInput.js
Created March 5, 2021 08:56
Formik Custom Input
import React from "react";
import { useField } from "formik";
const CustomInput = ({ label, ...props }) => {
const [field, meta] = useField(props);
return (
<div className="flex flex-col text-left">
{label && <label htmlFor={props.id || props.name}>{label}</label>}
<input
@sagarPakhrin
sagarPakhrin / nearby-coordinates.sql
Created January 12, 2021 08:56 — forked from statickidz/nearby-coordinates.sql
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@sagarPakhrin
sagarPakhrin / machine.js
Last active November 17, 2020 11:52
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@sagarPakhrin
sagarPakhrin / machine.js
Created November 16, 2020 07:49
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
import axios from "axios";
const baseURL = process.env.API_URL
? process.env.API_URL
: "http://127.0.0.1:8000/api/v1/";
const axiosInstance = axios.create({
baseURL: baseURL,
timeout: 5000,
headers: {