Skip to content

Instantly share code, notes, and snippets.

View Muqsit's full-sized avatar
👑
A beacon of hope.

Muqsit Muqsit

👑
A beacon of hope.
View GitHub Profile
@Muqsit
Muqsit / setting-up-raspberry-pi-ttl.md
Last active September 28, 2021 04:27
Setting up Raspberry Pi (4) to access via TTL

Steps

  1. Install Raspberry Pi OS image and "Raspberry Pi Imager" software from https://www.raspberrypi.org/software/
  2. Flash OS image via Raspberry Pi Imager
  3. Open E:\config.txt (assuming E:\ is the drive the image was flashed on to)
  4. Add enable_uart=1 under the [all] section (the section is most likely at the end of file)
  5. Add dtoverlay=disable-bt under the [all] section
  6. Insert SD card in Raspberry Pi
  7. Connect to device via serial line at speed=115200

Precautions

@Muqsit
Muqsit / btree.php
Last active April 21, 2021 22:23
B-Tree in PHP test implementation
<?php
declare(strict_types=1);
final class Node{
public static function buildTree(int $size, ?Node $node = null) : self{
$node ??= new Node();
$node->entries[0] = new Node();
$node->entries[1] = new Node();
<?php
declare(strict_types=1);
/**
* @name InventoryTransactionEventTest
* @main muqsit\testing\InventoryTransactionEventTest
* @api 4.0.0
* @version 0.0.1
*/
@Muqsit
Muqsit / OnlinePlayerIterator.php
Last active October 4, 2020 09:38
OnlinePlayerIterator.php
<?php
declare(strict_types=1);
final class Player{
/** @var int */
public $id;
/** @var bool */
@Muqsit
Muqsit / XboxLiveAPI.php
Created June 7, 2020 06:04
Xbox Live Web Authentication
<?php
declare(strict_types=1);
final class XboxLiveAPI{
private static function parseJsonResponse(string $response) : array{
$data = json_decode($response, true);
if(isset($data["error"])){
throw new ErrorException("{$data["error"]}: {$data["error_description"]}");
<?php
declare(strict_types=1);
$db = $argv[1];
$host = $argv[2];
$user = $argv[3];
$pwd = $argv[4];
$mysql = new mysqli($host, $user, $pwd, $db);
@Muqsit
Muqsit / pc-pe-mapping.json
Created April 17, 2020 14:58
PC -> PE block:meta mapping
{
"3:2": "243:0",
"29:2": "29:3",
"29:3": "29:2",
"29:4": "29:5",
"29:5": "29:4",
"31:0": "32:0",
"33:2": "33:3",
"33:3": "33:2",
"33:4": "33:5",
@Muqsit
Muqsit / Loader.php
Created April 8, 2020 01:58
low budget specter that respawns
<?php
declare(strict_types=1);
namespace muqsit\fakeplayer;
use pocketmine\entity\Skin;
use pocketmine\event\Listener;
use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\PacketSender;
@Muqsit
Muqsit / percentage_random.php
Created April 7, 2020 19:34
random bool by percentage
<?php
const TESTS = 1000000;
function getPercentageBool(float $percentage) : bool{
return (mt_rand() / mt_getrandmax()) <= ($percentage * 0.01);
}
for($numbers = 0; $numbers < 10; ++$numbers){
$percentage = mt_rand(0, 99) + lcg_value();
@Muqsit
Muqsit / parse_mc_server_list.php
Created February 18, 2020 17:31
A script that parses server ip:port from minecraftpocket-servers.com
<?php
$pages = (int) $argv[1];
$output = $argv[2];
if(file_exists($output)){
echo "File " . $output . " already exists." . PHP_EOL;
return;
}