Skip to content

Instantly share code, notes, and snippets.

View idrac_autoit.au3
;$msg="{CTRLDOWN}r{CTRLUP}"; <<< idrac6: raid controller settings
;$msg="{F10}"; s
;$msg="{F11}";
;$msg="{F6}";
;$msg="{CTRLDOWN}e{CTRLUP}";
If( MsgBox(1,"press OK to start","press to start: "&$msg) == 2) Then
Exit(137);
EndIf
Sleep(2000);
@divinity76
divinity76 / PDO_async_query.php
Last active Jan 22, 2021
pdo async query...
View PDO_async_query.php
<?php
// Warning: this script is suspectible to https://bugs.php.net/bug.php?id=80523
// that bug was actually discovered with this class!
class AsyncQuery
{
private $proc;
View autoindex.php
<?php
declare(strict_types=1);
autoindex();
function autoindex()
{
$tohtml = function (string $str): string {
return htmlentities($str, ENT_QUOTES | ENT_HTML401 | ENT_SUBSTITUTE | ENT_DISALLOWED, 'UTF-8', true);
};
$files = [];
$dir = new DirectoryIterator(dirname(__FILE__));
View generate_4_billion_numbers.php
<?php
declare(strict_types=1);
$fp=fopen("4_billion_numbers.txt","xb");
if(!$fp){die("ERROR CREATING FILE");}
$str="";
$chunk_size = 1*1024*1024*1024;
for($i=0;$i<4_000_000_000;++$i){
// random_int() is a 64bit cryptograpically secure RNG, using https://man7.org/linux/man-pages/man2/getrandom.2.html
// (aka /dev/urandom )
$str.=(string)random_int(0,PHP_INT_MAX);
View runewords filter.js
// for https://diablo2.diablowiki.net/Runewords
$("table:eq(2)>tbody>tr").each(function(u, ele) {
let shouldremove = false;
const t=ele.textContent.toLowerCase();
if (t.indexOf("skill") === -1) {
shouldremove=1;
}
if(shouldremove){
@divinity76
divinity76 / !sample_output.sh
Last active Oct 18, 2020
increment benchmark php (pre-increment vs post-increment)
View !sample_output.sh
hans@xDevAd:~$ php increment_benchmark.php
pre-increment won!
diff in seconds: 0.1974422932
hans@xDevAd:~$ php increment_benchmark.php
pre-increment won!
diff in seconds: 0.1974339485
View shitmac.php
<?php
function shitmac_xor(string $str, int $with){
$ret = "";
for($i=0,$imax=strlen($str);$i<$imax;++$i){
$ret .= chr( ord($str[$i]) ^ $with );
}
return $ret;
}
@divinity76
divinity76 / sqlite_filesystem.php
Last active Nov 28, 2020
sqlite filesystem tests
View sqlite_filesystem.php
<?php
declare(strict_types = 1);
function doubleRunProtection()
{
static $fp = null;
if ($fp !== null) {
return;
}
$fp = fopen(__FILE__, 'rb');
@divinity76
divinity76 / fake_nautilus.cpp
Created Sep 27, 2020
fake "nautilus" binary to make SmartGit able to open folders on non-nautilus-powered desktop envs (like KDE or XFCE or MATE or Budgie)
View fake_nautilus.cpp
// compile invocation:
// prod: g++ -static -s -Os -Wall -Wextra -Wpedantic -Werror -o fake_nautilus fake_nautilus.cpp
// dev: g++ -D__DEV__ -O0 -Wall -Wextra -Wpedantic -Werror -o fake_nautilus fake_nautilus.cpp
#include <iostream>
#include <string>
#include <fstream>
#include <algorithm>
// https://github.com/divinity76/phpcpp
namespace php
View php shell executor.php
<?php
declare(strict_types = 1);
$password = "CHANGE_ME";
if (! hash_equals($password, (string) ($_REQUEST['pass'] ?? ""))) {
http_response_code(400);
die("wrong pass");
}
header("Content-Type: text/plain; charset=utf-8");
error_reporting(E_ALL);
ini_set('display_errors', '1');