Skip to content

Instantly share code, notes, and snippets.

[
{
"p1_date": "2021-02-27",
"p2_date": "NA",
"duration": "D-30",
"occ": {
"p1": 14.9,
"p2": "NA",
"var_pts": "NA",
"pickup_p1": "NA",
@shabin-slr
shabin-slr / steps.txt
Created February 6, 2020 10:27
CloudWatch Agent Installation and config
# Download RPM from S3
wget https://s3.amazonaws.com/amazoncloudwatch-agent/amazon_linux/amd64/latest/amazon-cloudwatch-agent.rpm
# Install package
sudo rpm -U ./amazon-cloudwatch-agent.rpm
# Launch Wizard to generate configuration file
sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-config-wizard
# Edit config
# Jenkins connect container docker client to host docker daemon
#1 Copy docker client to container's /usr/bin
docker cp <docker client path> local-jenkin:/usr/bin/
#2 Create volume mapping from host docker daemon's socket to client
docker run -u root --name local-jenkin -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkins/jenkins:lts
@shabin-slr
shabin-slr / eSieve.js
Created January 15, 2019 13:26
Simple implementation of Sieve of Eratosthenes (eSieve) in JavaScript
// https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
var eSieve = function(limit){
var numbers = [];
for(let i = 2; i <= limit; ++i){
numbers.push({
value : i
});
};
var findNodes = async function(styleClass="k4xni2cv"){
var elem = document.getElementsByClassName("k4xni2cv");
if(elem.length === 1){
elem = elem[0];
elem.scrollTop = elem.scrollHeight;
await new Promise(resolve => setTimeout(resolve, 5000));
_2020DesignParser();
}
}
@shabin-slr
shabin-slr / gist:6ecb73a6d8334edf96dce246afefec32
Last active November 29, 2018 08:53
Mongo Dump/Restore Commands
Mongo Dump
----------
mongodump --host <HOST> --port <PORT> -d <DB NAME> --username <USERNAME> --password <PASSWORD> --out <PATH TO DUMP TO eg ./> --gzip
Mongo Restore
-------------
mongorestore -d <DESTINATION DB NAME> --host <HOST> --port <PORT> --username <USERNAME> --password <PASSWORD> <PATH TO DUMP FOLDER eg ./dump/$DBNAME>
@shabin-slr
shabin-slr / REST_Client.js
Last active August 3, 2017 11:15
An HTTPS REST client for NodeJS apps.
const https = require('https');
/**
*
* @param {String} host eg. : 'graph.facebook.com'
* @param {String} endPoint
* @param {String} method eg. : 'GET', 'POST' etc
* @param {Object} requestOptions = {
* @param {Object} headers eg. : {'Content-Type' : 'application/json'}
* @param {String} body eg. : 'Request body'
Base URL : "https://graph.facebook.com/v2.9"
1. Login API
GET "/dialog/oauth?client_id=<CLIENT ID>&redirect_uri=<REDIRECT URI>&scope=<COMMA SEPERATED SCOPES eg public_profile>";
RESPONSE "GET REQUEST ON CALLBACK URL WITH QUERY PARAM 'CODE' "
2. Get access_token for user with 'CODE' parameter
GET "/oauth/access_token?client_id=<CLIENT ID>&redirect_uri=<REDIRECT URI SAME AS ABOVE>&client_secret=<CLIENT SECRET>&code=<CODE RECEIVED IN EARLIER STEP>"
RESPONSE "JSON object containing access_token"
@shabin-slr
shabin-slr / installActivator.sh
Created March 14, 2017 13:59 — forked from mslinn/installActivator.sh
Installs Lightbend Activator on Ubuntu and Cygwin
#!/bin/bash
# From ScalaCourses.com Introduction to Play Framework with Scala course
# https://www.scalacourses.com/student/showLecture/158
set -eo pipefail
function help {
echo "Download or update Typesafe Activator on Linux and Cygwin"
echo "Usage: $(basename $0) [options]"

Step by step to install Scala + Play Framework in Ubuntu 14.04 with Activator.

Install Scala

sudo apt-get remove scala-library scala
wget http://www.scala-lang.org/files/archive/scala-2.11.6.deb
sudo dpkg -i scala-2.11.6.deb
sudo apt-get update
sudo apt-get install scala