Skip to content

Instantly share code, notes, and snippets.

View Paulius11's full-sized avatar
🌍

Paulius Paulius11

🌍
  • Lithuania
View GitHub Profile
@Paulius11
Paulius11 / meta.py
Created March 28, 2023 11:50
python meta and __new__
# Creating sigleton
class Singleton:
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = super().__new__(cls)
return cls._instance
def __init__(self):
@Paulius11
Paulius11 / deck_of_cards.py
Created February 21, 2023 07:18
Python create deck of cards
from pprint import pprint
from itertools import product
suits = ['♠️', '♣️', '♥️', '♦️']
values = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'jack', 'queen', 'king', 'ace']
deck = list(product(suits, values))
pprint(deck, compact=False)
@Paulius11
Paulius11 / parse_icmp_sockets.py
Last active February 15, 2023 09:35
Parse ICMP packet with sockets
import socket
import struct
# create a raw socket that listens for ICMP packets
icmp = socket.getprotobyname('icmp')
sock = socket.socket(socket.AF_INET, socket.SOCK_RAW, icmp)
while True:
packet, address = sock.recvfrom(1024)
print(len(packet))
import Web3 from "web3";
import ERC20ABI from './abi/api-moonDoge.js';
const tokenData = async (token = "") => {
const web3 = new Web3(
new Web3.providers.HttpProvider("https://bsc-dataseed1.binance.org:443")
);
if (!token) {
var customToken = new web3.eth.Contract(
ERC20ABI,
@Paulius11
Paulius11 / honey.js
Created March 11, 2021 12:17
xdai-honey
# Running your own xdai done
# # # # # # # # # # # # # # # # # #
https://forum.1hive.org/t/run-your-own-xdai-node/2875/8
# The graph api
# # # # # # # # # # # # # # # # # #
https://thegraph.com/explorer/subgraph/1hive/uniswap-v2
POST: https://api.thegraph.com/subgraphs/name/1hive/uniswap-v2
@Paulius11
Paulius11 / react.js
Last active June 4, 2020 10:32
React snippets
# Elementu išpakavimas
{lists.map(list => <li>{list.projectName}</li>)}
# Funkcinio elemento hookai ir axios
const [lists, setprojects] = useState([]);
useEffect(() => {
axios
.get("http://localhost:9090/api/project")
@Paulius11
Paulius11 / snippet.java
Created April 10, 2020 04:12
java snippet
#Random
## Secure random generating
private static final int NUMBER_OF_CARDS = 52;
private static final SecureRandom randomNumbers = new SecureRandom();
int second = randomNumbers.nextInt(NUMBER_OF_CARDS)
#Printing
##Printing values with leading zeros 0:
System.out.printf("valu:e %s%n", counter );