Skip to content

Instantly share code, notes, and snippets.

Avatar

Rohit Bhute rvbhute

View GitHub Profile
@rvbhute
rvbhute / t.sh
Created Feb 1, 2019
Bash script to dump task log to a file
View t.sh
#! /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"
@rvbhute
rvbhute / DNSMasq_withMalwareBlocking.md
Created May 26, 2018 — forked from erlepereira/DNSMasq_withMalwareBlocking.md
Using DNSMasq as a caching nameserver & add in a malware etc blocking
View DNSMasq_withMalwareBlocking.md

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`
View mysql-to-postgresql.md

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.
View map.js
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;
@rvbhute
rvbhute / postgres-cheatsheet.md
Created Nov 23, 2017 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet
View postgres-cheatsheet.md

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@rvbhute
rvbhute / gist:3937ff7c414f774b85cf
Created Jan 8, 2016
output of curl command for all 3 ISP
View gist:3937ff7c414f774b85cf
rohit@ryujin:~$ curl -v https://deb.nodesource.com
* Rebuilt URL to: https://deb.nodesource.com/
* Hostname was NOT found in DNS cache
* Trying 192.241.233.42...
* Trying 2604:a880:1:20::13b:b001...
* connect to 2604:a880:1:20::13b:b001 port 443 failed: Network is unreachable
* Failed to connect to deb.nodesource.com port 443: Network is unreachable
* Closing connection 0
curl: (7) Failed to connect to deb.nodesource.com port 443: Network is unreachable
@rvbhute
rvbhute / gist:2dac82a5a5d40ebc9c2b
Last active Jan 8, 2016
apt errors on deb.nodesource.com
View gist:2dac82a5a5d40ebc9c2b
rohit@ryujin:~$ curl -v https://deb.nodesource.com
* Rebuilt URL to: https://deb.nodesource.com/
* Hostname was NOT found in DNS cache
* Trying 192.241.233.42...
* Trying 2604:a880:1:20::13b:b001...
* connect to 2604:a880:1:20::13b:b001 port 443 failed: Network is unreachable
* Failed to connect to deb.nodesource.com port 443: Network is unreachable
* Closing connection 0
curl: (7) Failed to connect to deb.nodesource.com port 443: Network is unreachable
View gist:6315810
<?php
$sendToQueue = function($num) {
$parameters = []; // parameters including $num
Rabbit::enqueue('comms', 'sms', $parameters, 'topic');
};
array_walk($numbers, $sendToQueue($num));
@rvbhute
rvbhute / create-cbz.desktop
Created Apr 10, 2013
Custom KDE service menu entry to create a CBZ archive from a directory of images. Drop this file in your service menu folder - ~/.kde/share/kde4/services
View create-cbz.desktop
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=createCBZ
[Desktop Action createCBZ]
Name=Create CBZ
Exec=zip "%u.cbz" %u/*.*
Icon=ark
@rvbhute
rvbhute / create-cbz.sh
Created Apr 4, 2013
Two versions for creating CBZ (Comic Book archive) files out of a directory of images. These files can be opened in comic readers. In Linux, applications like Evince also handle CBZ files with ease.
View create-cbz.sh
#!/bin/sh
# First version, to use only a particular file-type in a folder
for f in `ls -l | egrep '^d' | awk '{print $NF}'`
do
cd $f
zip $f.cbz *.jpg
mv $f.cbz ../$f.cbz
cd ..