2018-02-07

MongoDB - Upgrade standalone from v3.4 to v3.6


// Set the feature compatibility version to 3.4
db.adminCommand( { getParameter: 1, featureCompatibilityVersion: 1 } );
db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )

// Test and let your application season for a while

// Once convinced everything works, then set features compatibility version to 3.6
db.adminCommand( { setFeatureCompatibilityVersion: "3.6" } )

2018-01-06

MongoDB - Aggregation, simple group by single field with frequency count

db.[COLLECTION_NAME].aggregate([
    {"$group" : {_id:"$FIELD_TO_GROUP_BY", count:{$sum:1}}}
])

2017-11-08

MySQL - Select date with microseconds precision

SELECT DATE_FORMAT( CURRENT_TIMESTAMP, "%W %M %e %Y %f");
SELECT now(6);
SELECT MICROSECOND(now(6));

2017-10-12

Python - Replace three consecutive dot-space strings (. . . ) with triple dot (...)

import re
str = "This is one  . . .  . . This is two. And other."
print re.sub( r'((\. )\2{2,2})', '...', str)

2017-10-10

MacOS - How to verify a file's sha256 checksum

Terminal command:
openssl dgst -sha256 /PATH/FILE_NAME

Yields:
SHA256(/PATH/FILE_NAME)= 77aa9930be611ec3f4e72d74c897dac5a98b4e61884a4048d31e4597f9fbb9ff


2017-10-09

MySQL - GROUP_CONCAT Character Limit Setting

Run this session variable before your SQL.
Adjust the number of characters.

SET SESSION group_concat_max_len = 5000;

2017-09-27

MySQL - Table is "Read Only" error message


(1) Locate MySQL's data folder path (run this query, MySQL must be up and running).
select @@datadir;

(2) Change permissions so "mysql" can access it:
chown -Rf mysql:mysql /PATH_TO_DATA_FOLDER/data

(3) Restart MySQL.

(4) Re-attempt to make table/record changes.