Skip to content

Instantly share code, notes, and snippets.

divinity76

Block or report user

Report or block divinity76

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@divinity76
divinity76 / CryptedDebug.class.php
Last active Jan 22, 2020
encrypt/decrypt debug messages/backtraces
View CryptedDebug.class.php
<?php
declare(strict_types=1);
class CryptedDebug
{
private const CRYPT_KEY = 'CHANGE_ME_!!!';
private const FORMAT_VERSION = 1;
View X11 Dummy configuration.txt
# This xorg configuration file will start a dummy X11 server.
# move it to /etc/X11/xorg.conf
# don't forget apt install xserver-xorg-video-dummy;
# based on https://xpra.org/Xdummy.html
Section "ServerFlags"
Option "DontVTSwitch" "true"
Option "AllowMouseOpenFail" "true"
Option "PciForceNone" "true"
Option "AutoEnableDevices" "false"
@divinity76
divinity76 / fps_counter.php
Last active Jan 3, 2020
count videogame fps by inspecting video stream frame-by-frame - suggested tolerance: 0.4
View fps_counter.php
<?php
// TODO: investigate -enc_time_base -1 / AndreKR's comment here: https://superuser.com/questions/1512575/why-total-frame-count-is-different-in-ffmpeg-than-ffprobe/1512583?noredirect=1#comment2288790_1512583
declare (strict_types = 1);
//require_once('hhb_.inc.php');
const EXT = "png"; //jpg gives unreliable results (but significantly less disk space usage =/ )
init();
global $input_file, $tolerance;
// ffmpeg -i test_30.mp4 thumb%01d.png -hide_banner
$cmd = implode(" ", array(
escapeshellarg('ffmpeg'),
@divinity76
divinity76 / sql_searcher.php
Created Dec 20, 2019
search through an entire sql database for something, whatever the layout.
View sql_searcher.php
<?php
declare(strict_types=1);
const MODE = "SQLITE"; // MYSQL
const SEARCH_QUERIES = array(
'SELECT * FROM `@@TABLE@@` WHERE @@LEL@@ LIKE \'%Sma-data-1812%\' '
);
if (MODE === "SQLITE") {
View mysqldump example
TODO: filter out the ??string?? stuff
??--order-by-primary??
??--apply-slave-statements??
??--default-character-set=utf8mb4??
mysqldump --user=user_name --password --quick --insert-ignore --port=port_num --host=host_name --all-databases --no-autocommit --compress --add-locks --single-transaction --all-tablespaces --quote-names --allow-keywords --comments --complete-insert --create-options --dump-date --events --extended-insert --hex-blob --routines --set-charset
View misc PHP.php
<?php
function json_encode_pretty($data, int $extra_flags = 0, int $exclude_flags = 0): string
{
// prettiest flags for: 7.3.9
$flags = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | (defined("JSON_UNESCAPED_LINE_TERMINATORS") ? JSON_UNESCAPED_LINE_TERMINATORS : 0) | JSON_PRESERVE_ZERO_FRACTION | (defined("JSON_THROW_ON_ERROR") ? JSON_THROW_ON_ERROR : 0);
$flags = ($flags | $extra_flags) & ~ $exclude_flags;
return (json_encode($data, $flags));
}
View wget mirror
wget --adjust-extension --no-check-certificate --recursive --convert-links --mirror --page-requisites --no-parent --reject "*logout*"
View hash collision birthday paradox
https://preshing.com/20110504/hash-collision-probabilities/
given 2**32 possible hashes and 77163 samples, the chance of collision is 50%,
(function(){
let samples=2**32;// 77163
let hash_bytes=1;
for(;hash_bytes<30;++hash_bytes)
{
View guess_encoding.php
<?php
declare(strict_types=1);
function guess_encoding(string $str): string {
if($str===''){throw new \InvalidArgumentException('input string empty!');}
$blacklist = array (
'pass',
'auto',
'wchar',
'byte2be',
@divinity76
divinity76 / LoginGmail.php
Last active Oct 3, 2019
login to gmail.com with curl, pretending to be a browser.
View LoginGmail.php
<?php
declare(strict_types = 1);
// header ( "content-type: text/plain;charset=utf8" );
// https://github.com/divinity76/hhb_.inc.php/blob/master/hhb_.inc.php
require_once ('hhb_.inc.php');
function loginGmail(string $username, string $password, string $recoveryEmailChallengeAnswer) : \hhb_curl
{
$hc = new hhb_curl('', true);
$hc->setopt_array(array(
You can’t perform that action at this time.