Skip to content

Instantly share code, notes, and snippets.

View MakStashkevich's full-sized avatar
🍀
believe on the best

Maksim Stashkevich MakStashkevich

🍀
believe on the best
View GitHub Profile
@viclafouch
viclafouch / use-clipboard-api.js
Last active February 19, 2025 18:08
A custom React Hook for writing and reading from the modern clipboard API
// hooks/use-clipboard-api.js
import { useState, useCallback } from 'react'
function useClipboardApi() {
const [content, setContent] = useState(null)
const askPermission = useCallback(async queryName => {
try {
const permissionStatus = await navigator.permissions.query(queryName)
return permissionStatus.state === 'granted'
@samsonjs
samsonjs / PlatformDependentValue.swift
Created May 4, 2020 14:22 — forked from myell0w/PlatformDependentValue.swift
Cross-Platform Helpers for iOS/macOS
/// Used to identify traits of the current UI Environment - especially useful for cross-platform code
public struct MNCUITraits: Withable {
/// Does *not* identify the device type, but the idiom of the layout to apply
/// This means that e.g. on iPad the layoutIdiom can be `.phone`, if run in Split Screen or SlideOver
public enum LayoutIdiom {
case phone(hasRoundCorners: Bool)
case pad(hasRoundCorners: Bool)
case mac
}
@TwistedAsylumMC
TwistedAsylumMC / HotbarShortcuts.ahk
Created February 29, 2020 21:39
This script allows Windows 10 users to use the 1-9 keys in their inventories to act as shortcuts to easily move items in and out of their hotbar slots.
; Hotbar Shortcuts for Minecraft Bedrock Edition by TwistedAsylumMC
; This script allows Windows 10 users to use the 1-9 keys in their inventories
; to act as shortcuts to easily move items in and out of their hotbar slots.
; How to use this script:
; 1. Download AutoHotKey (If you haven't already) from https://www.autohotkey.com/download/
; 2. Save this file to your device and double click it to start the script
; 3. Load up your Minecraft client and go inside of a world
; 4. Inside your inventory, you can use the 1-9 keys to swap items around
@backslash-f
backslash-f / UIDeviceExtension.swift
Last active December 9, 2022 14:26
Get Apple device model / marketing Name
import UIKit
public enum ModelName: String {
case simulator
case iPod1, iPod2, iPod3, iPod4, iPod5
case iPad2, iPad3, iPad4, iPad5, iPad6
case iPadAir, iPadAir2, iPadAir3
case iPadMini, iPadMini2, iPadMini3, iPadMini4, iPadMini5
case iPadPro9_7, iPadPro10_5, iPadPro12_9, iPadPro2_12_9, iPadPro11, iPadPro3_12_9
case iPhone4, iPhone4S
@mlnor27
mlnor27 / useFetch.js
Last active November 23, 2022 09:32
"useFetch" - A little React hook to handle HTTP request
import { useEffect, useReducer, useRef } from "react";
const initialState = {
isLoading: false,
data: null,
err: null,
cancel: () => {}
};
const reducer = (state, { type, payload }) => {
@Frago9876543210
Frago9876543210 / dump.php
Last active September 30, 2021 11:50
bedrock_server packet tracer
<?php
declare(strict_types=1);
use pocketmine\network\mcpe\protocol\PacketPool;
use pocketmine\utils\BinaryDataException;
require_once "vendor/autoload.php";
$packetPool = PacketPool::getInstance();
nthreads CpuThread CpuProcess IoThread IoProcess
1.000000e+00 3.144138e-01 3.251026e-01 1.001459e+00 1.003092e+00
2.000000e+00 6.895385e-01 3.517330e-01 1.001673e+00 1.006315e+00
3.000000e+00 1.031855e+00 3.544722e-01 1.001369e+00 1.006683e+00
4.000000e+00 1.421367e+00 3.659563e-01 1.001482e+00 1.004262e+00
5.000000e+00 1.758888e+00 5.339592e-01 1.001763e+00 1.009259e+00
6.000000e+00 2.055879e+00 5.403588e-01 1.001714e+00 1.008378e+00
7.000000e+00 2.421100e+00 6.488514e-01 1.002105e+00 1.008495e+00
8.000000e+00 2.919692e+00 6.753159e-01 1.001981e+00 1.012398e+00
9.000000e+00 3.445944e+00 8.028872e-01 1.002099e+00 1.012729e+00
@MaximKotliar
MaximKotliar / AVPlayerDelegate.swift
Last active January 16, 2025 11:37
A easier way to handle AVPlayer's events
// AVPlayerDelegate.swift
//
// Created by Maxim Kotliar on 7/30/18.
//
import AVFoundation
@objc protocol AVPlayerDelegate: class {
@objc optional func playerDidStartPlayback()
@objc optional func playerDidPausePlayback()
@shankartshinde
shankartshinde / UIDeviceExtension.swift
Last active December 9, 2022 15:16
UIDevice as extension to determine current type of device/simulator in Swift
//
// UIDeviceExtension.swift
//
// Created by shankars on 3/15/19.
// Copyright © 2019 shankars. All rights reserved.
//
import Foundation
import UIKit
<?php
declare(strict_types=1);
use Mdanter\Ecc\Crypto\{Key\PrivateKeyInterface, Signature\Signature};
use Mdanter\Ecc\Serializer\PrivateKey\{DerPrivateKeySerializer, PemPrivateKeySerializer};
use Mdanter\Ecc\Serializer\PublicKey\{DerPublicKeySerializer, PemPublicKeySerializer};
use Mdanter\Ecc\Serializer\Signature\DerSignatureSerializer;
class JWT{