Skip to content

Instantly share code, notes, and snippets.

Rohit Bhute rvbhute

Block or report user

Report or block rvbhute

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
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 ractive.js
// my_list is an array of objects updated by ajax
var my_list = [{'id':1, 'name':'Jack'},{'id':2, 'name':'Robin'}];
// with lodash
var add_new_messages = function(data) {
var new_list = my_list;
new_list.push.apply(new_list, data);
new_list = _.uniq(new_list, 'id');
View apache_cors_example
# Sets CORS headers for request from example1.com and example2.com pages
# for both SSL and non-SSL
SetEnvIf Origin "^https?://[^/]*(example1|example2)\.com$" ORIGIN=$0
Header set Access-Control-Allow-Origin %{ORIGIN}e env=ORIGIN
Header set Access-Control-Allow-Credentials "true" env=ORIGIN
# Always set Vary: Origin when it's possible you may send CORS headers
Header merge Vary Origin
@rvbhute
rvbhute / mail vs Mail
Created Mar 10, 2015
Two ways to send emails from Laravel app
View mail vs Mail
mail('mail@serversforhackers.com', 'Feedback', 'This is so useful, thanks!');
Mail::send('emails.test', ['key' => 'value'], function($message)
{
$message->to('foo@example.com', 'John Smith')->subject('Welcome!');
});
You can’t perform that action at this time.