Skip to content

Instantly share code, notes, and snippets.

@divinity76
divinity76 / alibaba_quantity.js
Last active Apr 16, 2021
alibaba cheapest quantity checker (price+shipping)
View alibaba_quantity.js
o={
getTotal:function(){return Number(document.querySelectorAll(".sub-total-area")[0].textContent.match(/[0-9\,\.]+/)[0]);},
getUnits:function(){return Number(document.querySelectorAll("[data-role='wholesale-order-quantity']")[0].value);},
getPricePerUnit:function(){return (this.getTotal()/this.getUnits());},
};
prices={};
theClearInterval=setInterval(function(){
prices[o.getUnits()]=o.getPricePerUnit();
document.querySelectorAll("a.quantity-up")[0].click();
View shittyRecurringCompression.php
<?php
function shittyRecurringCompression(string $data):string{
$countRecurring=function(string $str):int{
$imax = min(0xFF,strlen($str));
if($imax===0){
return 0;
}
$startChar = $str[0];
@divinity76
divinity76 / cpptar.php
Last active Mar 12, 2021
files to c++ vector<tuple<string,string>> converter
View cpptar.php
<?php
declare(strict_types = 1);
$auto_ldd = true;
$add_template_cpp = true;
$files = [
"plink.exe" => '/cygdrive/c/Users/hansh/Downloads/plink.exe',
];
if (0) {
$files = [
"sh" => '/bin/sh'
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;
}