Skip to content

Instantly share code, notes, and snippets.

@countingpine
countingpine / mongo_prune_js.js
Created August 24, 2023 13:02 — forked from arevindh/mongo_prune_js.js
mongo_prune_js.js
// keep N-day worth of data
var days=7;
// change to false to have the script to really exclude old records
// from the database. While true, no change at all will be made to the DB
var dryrun=true;
var now = new Date().getTime(),
time_criteria = now ;
time_criteria_in_seconds = time_criteria / 1000;
@countingpine
countingpine / nc.php
Created June 22, 2023 16:46 — forked from miguelmota/nc.php
PHP send message to socket server (netcat)
<?php
$payload = 'hello world';
$stream = stream_socket_client("tcp://127.0.0.1:5555", $errno, $errstr);
if (!$stream) {
echo "{$errno}: {$errstr}\n";
die();
}
fwrite($stream, $payload);
stream_socket_shutdown($stream, STREAM_SHUT_WR);