Skip to content

Instantly share code, notes, and snippets.

View DaveRandom's full-sized avatar

Chris Wright DaveRandom

View GitHub Profile
<?php
include dirname(__DIR__) . "/vendor/autoload.php";
use Amp\Process\Process;
use function Amp\Promise\all;
const COUNT = 8;
$passwords = [];
<?php
class SeededRandomNumberGenerator
{
/**
* An integer with the 32 least significant bits set
* 0xffffffff is a float on 32-bit platforms :-/
*/
private const MASK = \PHP_INT_SIZE === 4 ? ~0 : 0xffffffff;
@DaveRandom
DaveRandom / rant.md
Last active February 2, 2024 16:18
Why you should not use relative paths when working with files in PHP

TL;DR do what the last section tells you to do

What is the difference between a relative path and an absolute path?

An absolute path is one which includes all path components from the root of the file system. It starts with a leading / on unix-like operating systems, or a drive letter on Windows.

Unix: /full/path/to/file.php

Windows C:\full\path\to\file.php

(function() {
'use strict';
/**
* Modifications to perform (processed in order)
*
* @type {Function[]}
*/
const modifications = [
(text) => text.replace(/!+/g, '!'),
@DaveRandom
DaveRandom / login.php
Created August 19, 2018 16:59 — forked from rahuldottech/login.php
PHP session management
<?php
require 'secsesh.php';
session_start();
if(/*credentials check out*/){
s_start();
}
header( 'Location: somePage.php' );
@DaveRandom
DaveRandom / php-script.bat
Created April 8, 2020 23:22
Execute batch file as PHP script (one line shebang for PHP scripts on Windows)
@(<nul set /p=#! & type ^"%~f0^") | php -- %* & goto :eof
<?php declare(strict_types=1);
// script goes here
var_dump($argv);
@DaveRandom
DaveRandom / InteractiveLogons.xml
Last active March 11, 2025 16:11
Windows log filter for finding interactive logon events
<QueryList>
<Query Id="0" Path="Security">
<Select Path="Security">
Event[
System[EventID=4624]
]
[
EventData[
Data[@Name='LogonType']
and (Data=2 or Data=7 or Data=10 or Data=11)