Skip to content

Instantly share code, notes, and snippets.

@Gorilaz
Gorilaz / curl.md
Created August 3, 2020 10:19 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.

@Gorilaz
Gorilaz / pgbouncer_centos8.sh
Created November 18, 2021 09:44 — forked from coder4web/pgbouncer_centos8.sh
CentOS 8 PgBouncer setup
# https://www.pgbouncer.org/install.html
# sudo dnf install pgbouncer
# Problem: package pgbouncer requires python-psycopg2, but none of the providers can be installed
# https://www.pgbouncer.org/install.html#building
sudo dnf install libevent libevent-devel
# https://www.pgbouncer.org/downloads/
wget -c https://www.pgbouncer.org/downloads/files/1.12.0/pgbouncer-1.12.0.tar.gz
tar xvfz pgbouncer-1.12.0.tar.gz
// I wanted to know the top five largest collections in my MongoDB database in
// terms of document count. This MongoDB-specific JavaScript gets the job done.
//
// Edit variables in the config section, then execute like so:
//
// mongo --quiet topCollections.js
// config
var dbname = 'FIXME';
var collectionNames = db.getCollectionNames(), stats = [];
collectionNames.forEach(function (n) { stats.push(db[n].stats()); });
stats = stats.sort(function(a, b) { return b['size'] - a['size']; });
for (var c in stats) { print(stats[c]['ns'] + ": " + stats[c]['size'] + " (" + stats[c]['storageSize'] + ")"); }
@Gorilaz
Gorilaz / findLongRunningOp.js
Created November 25, 2021 11:43 — forked from kylemclaren/findLongRunningOp.js
Find and (safely) kill long running MongoDB ops
db.currentOp().inprog.forEach(
function(op) {
if(op.secs_running > 5) printjson(op);
}
)
@Gorilaz
Gorilaz / 01_mongodb_live_hacking.md
Created December 13, 2021 06:14 — forked from ttrelle/01_mongodb_live_hacking.md
MongoDB Live Hacking Preparations

Download & Run MongoDB

  • Grab the latest stable release from the download page
  • Unzip the archive to a folder called ${MONGO_HOME} on your disk
  • Create a folder /data/db on the same drive/partition
  • Go to ${MONGO_HOME}/bin
  • Execute the binary mongod (or mongod.exe on Windows)

For a more detailed explanation, see the MongoDB installation guide.

SELECT table,
formatReadableSize(sum(bytes)) as size,
min(min_date) as min_date,
max(max_date) as max_date
FROM system.parts
WHERE active
GROUP BY table