Skip to content

Instantly share code, notes, and snippets.

View vikas17a's full-sized avatar

Vikas Aggarwal vikas17a

View GitHub Profile
@vikas17a
vikas17a / marsrover.rb
Last active August 29, 2015 14:22
Ruby Marsrover problem solution
class Rover
attr_reader :x
attr_reader :y
attr_reader :face
attr_reader :plot_x
attr_reader :plot_y
def initialize(x,y,face, plot_x, plot_y)
@x =x
@y =y
@face =face
####Importing Libraries#####
from bs4 import BeautifulSoup
import requests
import sys
#############################
########## IMDB URL #############
url = 'http://www.imdb.com/chart/top'
#################################

Setting up hastebin server

  • Set up and start redis server
  • Enter following command in clone
git clone https://github.com/seejohnrun/haste-server.git && cd haste-server/
cat config.js #setup configuration of hastebin server port and redis server port
npm install
npm start &> /dev/null/ &

User this server IP and Port in following steps to setup command line code paste to haste-server

@vikas17a
vikas17a / echo_server.py
Created July 13, 2015 07:59
A simple echo server
#!/usr/bin/env python
# Reflects the requests from HTTP methods GET, POST, PUT, and DELETE
# Written by Nathan Hamiel (2010)
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from optparse import OptionParser
class RequestHandler(BaseHTTPRequestHandler):
def do_GET(self):
@vikas17a
vikas17a / Readme.md
Last active August 29, 2015 14:25
Setting up two way authentication (PubKey + Google Authentication)

Instruction for setting up two way authentication (PubKey + Google Authenticator)

==

Installing pam for google-authenticator

sudo yum install make gcc pam-devel

TOTP (timebased one-time-password) security tokens are time sensitive. Hence, make sure that your system has ntpd running, and is configured to start the service at boot:

sudo yum install ntp
@vikas17a
vikas17a / automated_google_authentication.sh
Created July 16, 2015 12:19
google-authentication questionnaire automated
RESULT=$(google-authenticator <<!
y
y
y
n
y
!
)
echo $RESULT | awk '{print "QR Code URL:\n"$10}'
@vikas17a
vikas17a / testfab.py
Created July 22, 2015 06:13
Testing fabric with python
#!/usr/bin/env python
from fabric.api import *
def uptime():
local('uptime')
def remote_add():
local('git init')
local('git remote add origin https://github.com/vikas17a/testfab.git')
local('git pull origin master')
@vikas17a
vikas17a / Readme.md
Created July 28, 2015 07:54
Vault server setup

== Step to install vault

  • Download vault
wget https://dl.bintray.com/mitchellh/vault/vault_0.2.0_linux_386.zip
  • Create and edit config
    • Create config
@vikas17a
vikas17a / !README.md
Created September 2, 2015 16:03
Nagios plugin for check last updated ami

#Setting up nagios plugin for ami check

  • copy check_ami.py to your nagios plugin directory
  • give executable permission check_ami.py
  • copy config file in you nagios plugin directory add your id and key
  • change command file and add new command
define command{
    command_name    check_ami
    command_line    $USER1$/check_ami.py $ARG1$ $ARG2$ "$ARG3$"
}
@vikas17a
vikas17a / jsonlite.sh
Last active September 22, 2015 14:09
Enhanced Jsonlite
#!/bin/bash
set -e
VERSION="0.4.0"
COMMAND=$1
CWD=$(pwd);
case "$COMMAND" in
"set")