Skip to content

Instantly share code, notes, and snippets.

View sagar-gavhane's full-sized avatar
🏠
Working from home

Sagar sagar-gavhane

🏠
Working from home
View GitHub Profile
@sagar-gavhane
sagar-gavhane / .quotes.txt
Created December 27, 2024 18:22
.quotes.txt
"The only way to do great work is to love what you do." - Steve Jobs
"Strive not to be a success, but rather to be of value." - Albert Einstein
"The future belongs to those who believe in the beauty of their dreams." - Eleanor Roosevelt
"The best and most beautiful things in the world cannot be seen or even touched - they must be felt with the heart." - Helen Keller
"It is during our darkest moments that we must focus to see the light." - Aristotle Onassis
"Believe you can and you're halfway there." - Theodore Roosevelt
"The only limit to our realization of tomorrow will be our doubts of today." - Franklin D. Roosevelt
"The journey of a thousand miles begins with a single step." - Lao Tzu
"What you get by achieving your goals is not as important as what you become by achieving your goals." - Henry David Thoreau
"The mind is everything. What you think you become." - Buddha
@sagar-gavhane
sagar-gavhane / .zshrc
Created December 27, 2024 18:22
cowsay .zshrc
# Function to get a random quote from a file (same as before)
get_random_quote() {
local quote_file="$HOME/.quotes.txt"
if [[ ! -f "$quote_file" ]]; then
echo "Error: Quotes file '$quote_file' not found." >&2
return 1
fi
local num_lines=$(wc -l < "$quote_file")
local random_line=$((RANDOM % num_lines + 1))
sed -n "${random_line}p" "$quote_file"
@sagar-gavhane
sagar-gavhane / form_validation_lang.php
Created October 13, 2023 07:42
CodeIgniter validation errors
<?php
/**
* CodeIgniter
*
* An open source application development framework for PHP
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2019 - 2022, CodeIgniter Foundation
*
@sagar-gavhane
sagar-gavhane / multiple-form.js
Created August 7, 2021 07:27
use form to generate multiple forms with different submit button
import { useState } from "react";
import { useForm } from "react-hook-form";
function MyForm() {
const { register, handleSubmit } = useForm({
defaultValues: {
title: "",
description: ""
}
});
[
{
"type":"Component",
"id":"ImageAndText",
"label":"Image and Text",
"internal":false,
"isGlobal":false,
"allowNestedComponents":true,
"description":"Image and Text Row",
"attributes":{
@sagar-gavhane
sagar-gavhane / _descriptors.json
Created October 30, 2020 05:39
descriptor file for testing nested components
[{"type":"Component","id":"ImageAndText","label":"Image and Text","internal":false,"isGlobal":false,"allowNestedComponents":true,"description":"Image and Text Row","attributes":{"image":{"type":"Image","label":"Image","url":{"type":"String","label":"URL","default":""},"altText":{"type":"String","label":"Alt text","default":""}},"title":{"type":"String","label":"Title","default":""},"description":{"type":"String","label":"Description","default":""},"ctaText":{"type":"String","label":"Button text","default":""},"ctaLink":{"type":"String","label":"Button link","default":""},"boxes":{"type":"Array","label":"box","default":[],"allowNestedComponents":true,"children":{"type":"Shape","default":{},"children":{"title":{"type":"String","label":"box title","default":"box"}}}},"buttons":{"label":"my button","type":"Array","default":{},"allowNestedComponents":false,"children":{"type":"Shape","default":{},"children":{"buttonTitle":{"type":"String","label":"box title","default":""}}}}}},{"type":"Component","id":"RichText","l
@sagar-gavhane
sagar-gavhane / arrays-polyfill.js
Last active September 30, 2020 16:49
Polyfill of Array's map, filter and reduce methods
// reduce
Object.defineProperty(Array.prototype, 'myReduce', {
value: function(fn, initial) {
let values = this;
values.forEach((item, idx) => {
initial = fn(initial, item, idx)
})
return initial;
@sagar-gavhane
sagar-gavhane / combined-drivers-solution.js
Last active September 12, 2020 04:51
Combined drivers solution
function getMilliseconds(date) {
const [hourse, minute] = date.split(':')
return hourse*60*60 + minute*60
}
function sortingFn (a, z) {
return getMilliseconds(a[0]) - getMilliseconds(z[0])
}
function combinedDrivers(city1, city2) {
@sagar-gavhane
sagar-gavhane / hunts-for-forbidden-nesting.css
Created June 24, 2020 08:06
selector hunts for forbidden nesting
:not(figure) > figcaption,
:not(fieldset) > legend,
:not(dl) > :is(dt, dd),
:not(tr) > :is(td, th),
:not(select) > :is(option, optgroup),
:not(table) > :is(thead, tfoot, tbody, tr, colgroup, caption) {
outline: 2px dotted red;
}
@sagar-gavhane
sagar-gavhane / building-a-blog-with-next-js-pages-blog-slug.jsx
Last active June 1, 2020 05:59
Building a blog with Next.js: [Slug].jsx
// file: pages/blog/[slug].js
import React from "react";
function BlogPostPage(props) {
return (
<div>
<h1>{props.blog.title}</h1>
<section dangerouslySetInnerHTML={{ __html: props.blog.content }}></section>
</div>
);