Skip to content

Instantly share code, notes, and snippets.

Array.prototype.cmap = function(operation) {
var output = [];
for (var i = 0; i < this.length; i++) {
output[i] = operation(this[i]);
}
return output;
}
var addTwo = function (a) {
return a + 2;

Reasons for moving to from MySQL to PostgreSQL

  • Anecdotal - overall better DB out-of-the-box. Yes, MySQL can be made strict by tuning its settings but it is still catching up.
  • Character collation. Multi-lingual and emoji content necessitates UTF8. In MySQL, the "true" UTF8 is UTF8-MB4. We stumbled on this. PostgreSQL's collation is set to UTF8 OOTB and we had no surprises getting our content in and out.
  • Setting collation to utf8mb4 emits an index key length issue in older versions (n-1, n-2, etc.) of MySQL (as of 2017-18). These versions are the default in various Linux distros. To circumvent this, we had to limit indexed string columns to a specific length - which is not ideal. No such issues in PostgreSQL.
  • We needed the array data type (available in PostgreSQL) in one of our projects, and it was indexable too! PostgreSQL's JSON data type was also better than MySQL's.
@rvbhute
rvbhute / DNSMasq_withMalwareBlocking.md
Created May 26, 2018 05:06 — forked from erlepereira/DNSMasq_withMalwareBlocking.md
Using DNSMasq as a caching nameserver & add in a malware etc blocking

Assuming a Properly configured DNSMasq

a quickstart for dnsmasq is given at the end if you have not set it up yet.

something like this will add a great regularly updated malware file for it to use. More security and privacy to you! Specifically, this uses https://github.com/StevenBlack/hosts Choose one of the Raw Hosts file from there to use.

To setup DNSMasq, follow the below ...

wget -O- https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts | awk '$1 == "0.0.0.0" { print "address=/"$2"/0.0.0.0/"}' > /etc/dnsmasq.d/malware.conf`
@rvbhute
rvbhute / t.sh
Created February 1, 2019 16:32
Bash script to dump task log to a file
#! /bin/sh
# time log capture
set -e
time_stamp=$(date '+%Y-%m-%d %H:%M')
details="$@"
echo "[$time_stamp] $details" >> ~/Desktop/today.txt
notify-send --hint=int:transient:1 "Added log for $time_stamp"