Skip to content

Instantly share code, notes, and snippets.

View celeroncoder's full-sized avatar
:octocat:
Goofing around

Khushal Bhardwaj celeroncoder

:octocat:
Goofing around
View GitHub Profile
@celeroncoder
celeroncoder / README.md
Created March 21, 2021 10:37
Netlify Server Functions

Server Less Functions

Instructions

  • Create a netlify.toml file for using serverless functions on the website hosted on Netlify.
  • If any other hosting service search for the documentation for creating .toml file.
  • Put the functions in the functions directory in the root of the project.
  • Every function file must contain one export handler and only that will be valid and can be used.
    exports.handler = async function(event, context) {...};
@celeroncoder
celeroncoder / README.md
Created March 30, 2021 04:57
Cache Decorator in Python

Cache Decorator in Python

Description

  • In this directory it holds the implementation of cache Decorator in python.
  • We can use this decorator when we are using more computational power on stuff that has already been done.

Cache Decorator

  • Cache Decorator is a default Decorator in python from the built-in lib functools.
@celeroncoder
celeroncoder / README.md
Last active March 30, 2021 14:16
Secret Key Generator

Secret Key Generator

  • This is a secret key generator for generating 100 word, alphanumeric, random secret key to use in Django.
  • This uses python 3.6's default lib secrets and string to generate the key.
  • pyperclip library is to copy the key to the clipboard.

Usage

  • Copy the script and run the script that will print the secret key to the console and also copy that to the clipboard.
  • Install the sole dependencies(pyperclip) using the requirements.txt file.
@celeroncoder
celeroncoder / Main.java
Created May 20, 2021 15:49
Reporting Exceptions in Java
public class Main {
public static void main(String[] args) throws Exception { // if the method used within the function is expected to throw an exception the function must also said to be throw exception.
start();
}
public static void start() throws Exception {
try {
throw new Exception("This is a exception")
} catch (Exception e) { System.out.println(e) }
}
@celeroncoder
celeroncoder / httpLogger.ts
Last active September 11, 2024 17:24
Create a custom logger in TypeScript.
// Put in src/middlewares/
import morgan, { StreamOptions } from "morgan";
import Logger from "../utils/logger";
const stream: StreamOptions = {
write: message => Logger.http(message),
}
function skip():boolean {
@celeroncoder
celeroncoder / emailValidation.js
Last active February 27, 2022 15:02
Email Validation in Sanity Fields
export default {
name: "email",
title: "Email",
type: "string",
validation: (Rule) =>
Rule.regex(
/[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/,
{
name: "email",
invert: false,
@celeroncoder
celeroncoder / App.tsx
Last active April 8, 2022 16:59
Mantine Setup App Component
import {
MantineProvider,
ColorScheme,
ColorSchemeProvider,
} from "@mantine/core";
import { useHotkeys, useLocalStorage, useColorScheme } from "@mantine/hooks";
import MainComponent from "./MainComponent";
function App() {
const preferredColorScheme = useColorScheme();
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@celeroncoder
celeroncoder / index.html
Created July 21, 2022 08:05
Loading State Skeleton Grid of Cards
<div class="flex min-h-screen items-center p-10 flex-wrap justify-start gap-10 bg-gray-900">
<div class="w-[300px] flex-none">
<div class="relative space-y-5 rounded-2xl bg-white/5 p-4 overflow-hidden shadow-xl shadow-black/5 before:absolute before:inset-0 before:border-t before:border-rose-100/10 before:-translate-x-full before:animate-[shimmer_2s_infinite] before:bg-gradient-to-r before:from-transparent before:via-rose-100/20 before:to-transparent">
<div class="h-64 rounded-lg bg-rose-100/10"></div>
<div class="space-y-3">
<div class="h-3 w-3/5 rounded-lg bg-rose-100/10"></div>
<div class="h-3 w-4/5 rounded-lg bg-rose-100/20"></div>
<div class="h-3 w-2/5 rounded-lg bg-rose-100/20"></div>
</div>
</div>
@celeroncoder
celeroncoder / style.css
Created July 22, 2022 17:10
Hover Underline Animation
.hover-underline-animation {
display: inline-block;
position: relative;
}
.hover-underline-animation:after {
content: '';
position: absolute;
width: 100%;
transform: scaleX(0);