Skip to content

Instantly share code, notes, and snippets.

View RatanShreshtha's full-sized avatar

Ratan Kulshreshtha RatanShreshtha

View GitHub Profile

Keybase proof

I hereby claim:

  • I am ratanshreshtha on github.
  • I am ratanshreshtha (https://keybase.io/ratanshreshtha) on keybase.
  • I have a public key ASCPCjd7bHM1Ob9S4jX4Lxd7AC5Ne-doeS-2AaewlmeSaAo

To claim this, I am signing this object:

@RatanShreshtha
RatanShreshtha / rail-road.md
Last active July 10, 2018 12:13
Rail road diagram for regex used for url extraction.

Here is rail road diagram for summer training bot in #dgplug to extract links from logs.

Here is the regex used for url extraction.

r'(https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9][a-zA-Z0-9-]+\.[^\s]{2,}|www\.[a-zA-Z0-9][a-zA-Z0-9-]+\.[^\s]{2,}|https?:\/\/(?:www\.|(?!www))[a-zA-Z0-9]\.[^\s]{2,}|www\.[a-zA-Z0-9]\.[^\s]{2,})'

rail-road.png

3. Maintain .env for each project: put secrets/tokens in your .env file for each

# In your .env file

export accountSid='zuhvu87468KFYHJ0987-jmbhjhbhvfhh234BGUJ';
export authToken='nbkgjk-9jhj9876-87tnmjjk-knjbb-234-JHHYU-JBjhhmb';

Now to access these variable just refer to enviornment variables from inside of your code.

2. Export all secrets to your shell: put secrets/tokens in your .bash_profile/.bashrc file

# In your .bash_profile/.bashrc file

export accountSid='zuhvu87468KFYHJ0987-jmbhjhbhvfhh234BGUJ';
export authToken='nbkgjk-9jhj9876-87tnmjjk-knjbb-234-JHHYU-JBjhhmb';
@RatanShreshtha
RatanShreshtha / Secrets and Tokens (Naive).md
Last active January 4, 2018 11:27
How to manage API secrets/tokens and other tokens/keys and keep them secret for your deployments?

1. The Naive Approach: In case of hard coding

const accountSid = 'zuhvu87468KFYHJ0987-jmbhjhbhvfhh234BGUJ';
const authToken = 'nbkgjk-9jhj9876-87tnmjjk-knjbb-234-JHHYU-JBjhhmb';
const Twilio = require('twilio');
const client = new Twilio(accountSid, authToken);
client.messages
  .create({
 to: '+1987654323876',
@RatanShreshtha
RatanShreshtha / ps1.sh
Created October 11, 2017 11:47
My PS1
# Set symbols and colors here
triangle=$'\uE0B0'
# function to set username and host in the prompt
function prompt_user_and_host() {
echo -e "\e[1;37;44m $(users) @ $(hostname) \e[0m\e[34;100m$triangle\e[0m"
}
# function to set directories in the prompt
function prompt_dirs() {