Skip to content

Instantly share code, notes, and snippets.

View leopard627's full-sized avatar
🦖
Working from home

Leopard627 leopard627

🦖
Working from home
View GitHub Profile
@leopard627
leopard627 / MyNFT.sol
Created August 12, 2023 03:08 — forked from shobhitic/MyNFT.sol
Simple NFT Staking Smart Contract - https://youtu.be/m0w6JyqJKks
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/[email protected]/token/ERC721/ERC721.sol";
import "@openzeppelin/[email protected]/access/Ownable.sol";
contract MyNFT is ERC721, Ownable {
uint256 public totalSupply;
constructor() ERC721("MyNFT", "MNFT") {}
@leopard627
leopard627 / [email protected]
Created May 11, 2023 03:56
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.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
@leopard627
leopard627 / [email protected]
Created May 11, 2023 03:53
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.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
@leopard627
leopard627 / dnsovertls.md
Created January 4, 2023 11:47 — forked from uraimo/dnsovertls.md
Configure your Mac to use DNS over TLS
@leopard627
leopard627 / dummy_views.py
Created November 15, 2020 12:12
asyicIO with django view
import asyncio
loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
def send_email_with_asyncio(user, email):
# email sending logic
# .........................
# .................................
# asyncio/events.py in get_event_loop at line 602
not self._local._set_called and
isinstance(threading.current_thread(), threading._MainThread)):
self.set_event_loop(self.new_event_loop())
if self._local._loop is None:
raise RuntimeError('There is no current event loop in thread %r.'
% threading.current_thread().name)
return self._local._loop
def set_event_loop(self, loop):
@leopard627
leopard627 / read-access.sql
Created November 13, 2020 07:42 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
class Movie(models.Model):
title = models.CharField()
rate = models.FloatField()
......
....
...
.......
class Movie(models.Model):
rate = models.FloatField()
q1 = Movie.objects.filter(rate=1.0).count()
q2 = Movie.objects.filter(rate=2.0).count()
q3 = Movie.objects.filter(rate=3.0).count()
q4 = Movie.objects.filter(rate=4.0).count()
q5 = Movie.objects.filter(rate=5.0).count()
import datetime
KST = datetime.timezone(datetime.timedelta(hours=9))
kst_now = datetime.datetime.now(KST)