Skip to content

Instantly share code, notes, and snippets.

View dhananjayhegde's full-sized avatar

Dhananjay Hegde dhananjayhegde

  • TATA Consultancy Services
  • Bangalore
View GitHub Profile
@dhananjayhegde
dhananjayhegde / VideoCard.jsx
Last active July 29, 2023 13:48
Local Storage with React Component - store the state
import React, { useEffect, useState } from "react";
import "./VideoCard.css";
import { useNavigate } from "react-router-dom";
import { MdOutlineWatchLater } from "react-icons/md";
import { useData } from "../../context/DataContext";
export const VideoCard = ({ videoInfo }) => {
const { title, creator, thumbnail, views, category, _id } = videoInfo;
const navigate = useNavigate();
const { dispatch } = useData();
@dhananjayhegde
dhananjayhegde / ListReportExt.controller.js
Created June 24, 2022 06:49
Wrap OData v2 model read into a Promise
sap.ui.define(
[], function(){
"use strict";
return sap.ui.controller("todo.app.todoapp1.ext.controller.ListReportExt", {
promiseToRead: function(sPath){
var oModel = this.oModel;
return new Promise(function(resolveCallback, rejectCallback){
@dhananjayhegde
dhananjayhegde / contracts...dnote.sol
Created January 11, 2022 14:16
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// This line imports the ERC-20 token standard from OpenZeppelin (OZ). OZ is an Ethereum security company.
// Among other things, OZ develops reference contracts for popular smart contract standards which are thoroughly
// tested and secure. Whenever implementing a smart contract which needs to comply with a standard, try to
// find an OZ reference implementation rather than rewriting the entire standard from scratch.
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol";
@dhananjayhegde
dhananjayhegde / contracts...FundMe.sol
Created December 7, 2021 03:06
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=false&runs=200&gist=
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
// to get latest price data
import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
@dhananjayhegde
dhananjayhegde / contracts...FundMe.sol
Created December 5, 2021 16:50
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.9.0;
contract FundMe {
mapping(address => uint256) public addressToAmountFunded;
// "payable" function -> accespts payment
// Every transaction has some inbuilt variables
// "msg"
@dhananjayhegde
dhananjayhegde / contracts...StorageFactory.sol
Created December 5, 2021 14:55
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
import "./SimpleStorage.sol";
// This is a contract that will let you create and deploy SimpleStorage contracts
// A Contract that creates other contracts - Contract Factory
// In the end, we also inherited SimpleStorage here so that
// SimpleStorageFactory gets all functionalities of SimpleStorage
@dhananjayhegde
dhananjayhegde / contracts...SimpleStorage.sol
Created December 5, 2021 14:23
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.1+commit.df193b15.js&optimize=undefined&runs=undefined&gist=
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.1;
contract SimpleStorage{
struct People {
uint256 favoriteNumber;
string name;
}