Skip to content

Instantly share code, notes, and snippets.

View P7h's full-sized avatar

Prashanth Babu P7h

  • London, UK
View GitHub Profile
@P7h
P7h / MyAliases.sh
Last active December 27, 2015 06:49
Various aliases set up for my convenience on my Linux machine. Copy these to your .bashrc.
alias install="sudo apt-get install"
alias poweroff="sudo shutdown -h now"
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias d='ls'
alias df='df -h -x supermount'
alias du='du -h'
alias egrep='egrep --color'
@P7h
P7h / LinuxMint15To16Upgrade.sh
Created December 10, 2013 16:51
Steps to be performed for upgrading Linux Mint 15 "Olivia" to Linux Mint 16 "Petra".
sudo sed -i 's/raring/saucy/' /etc/apt/sources.list
sudo sed -i 's/olivia/petra/' /etc/apt/sources.list
sudo sed -i 's/raring/saucy/' /etc/apt/sources.list.d/official-package-repositories.list
sudo sed -i 's/olivia/petra/' /etc/apt/sources.list.d/official-package-repositories.list
sudo apt-get update && sudo apt-get dist-upgrade
sudo apt-get upgrade
@P7h
P7h / ResizeDiskEC2.sh
Created December 12, 2013 18:12
Script useful to resize or extend a disk on EC2
#Verify the disk space on the machine and note the partition names.
df -h
#Using the partition name above, resize the disk
sudo resize2fs /dev/xvde1
#Verify if the resizing was successful
df -h
@P7h
P7h / RHEL_Essentials.sh
Created December 12, 2013 18:25
Install essentials on RHEL machines.
sudo yum update
sudo yum install zip subversion git python2.7-dev
sudo yum install libcurl4-gnutls-dev librtmp-dev
sudo yum install gcc python-devel
sudo wget http://pkgs.repoforge.org/p7zip/p7zip-9.20.1-1.el6.rf.x86_64.rpm
sudo rpm -i p7zip-9.20.1-1.el6.rf.x86_64.rpm
sudo easy_install pip
@P7h
P7h / EC2_SSH_ClientAccess.sh
Last active January 22, 2016 03:12
To connect to EC2 env in a SSH Client, the following Gist has to be updated for a specific machine, source and final folders and also the Pub file.
pscp -i some.ppk SSH_Client_Pub.pub [email protected]:/root/.ssh/
ssh -i some.pem [email protected]
ssh-keygen -f ~/.ssh/SSH_Client_Pub.pub -i >> ~/.ssh/authorized_keys
scp -i ~/.ssh/id_rsa -o "UserKnownHostsFile /dev/null" -o StrictHostKeyChecking=no -r SRC_FOLDER [email protected]:DEST_FOLDER
@P7h
P7h / sudo_no_password.sh
Created December 12, 2013 18:56
sudo for a command without a password prompt.
#Be on high alert while modifying this file.
#There should be no scope any error.
#Open the file
sudo visudo -f /etc/sudoers
#Add this line or modify the username for whom sudo command will not prompt for the password.
prash ALL=(ALL) NOPASSWD: ALL
@P7h
P7h / ReadPropertiesWithGuava.java
Last active September 5, 2019 16:30
Load a properties file using Guava.
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Properties;
import com.google.common.io.ByteSource;
import com.google.common.io.Resources;
/**
* Reads a properties file and print all the key value pairs to the console.
@P7h
P7h / StopwatchExample.java
Created January 29, 2014 16:01
Sample example demonstrating usage of Stopwatch API of Google Guava.
import java.util.Random;
import java.util.concurrent.TimeUnit;
import com.google.common.base.Stopwatch;
/**
* Sample example demonstrating usage of Stopwatch API of Google Guava.
*
* @see <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/base/Stopwatch.html">Guava Stopwatch</a>
*/
@P7h
P7h / jdk_download.sh
Last active July 31, 2024 06:46
Script to download JDK / JRE / Java binaries from Oracle website from terminal / shell / command line / command prompt
##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### ##### #####
### Shell script to download Oracle JDK / JRE / Java binaries from Oracle website using terminal / command / shell prompt using wget.
### You can download all the binaries one-shot by just giving the BASE_URL.
### Script might be useful if you need Oracle JDK on Amazon EC2 env.
### Script is updated for every JDK release.
### Features:-
# 1. Resumes a broken / interrupted [previous] download, if any.
# 2. Renames the file to a proper name with including platform info.
@P7h
P7h / chromium_download.sh
Last active April 15, 2016 02:15
Commands to download Chromium from the shell. Just in case, if you dont want to go thru this hassle, check Chromium Auto Updater. http://www.firstever.eu/en/chromium-auto-updater.
# This script lists down commands to download Chromium [both 32 and 64 bit] from the shell.
#Just in case, if you dont want to go thru this hassle, check Chromium Auto Updater. http://www.firstever.eu/en/chromium-auto-updater.
#Steps for downloading 32 bit Chromium for Windows.
export ver=`curl http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/LAST_CHANGE`
echo $ver
wget http://commondatastorage.googleapis.com/chromium-browser-continuous/Win/$ver/chrome-win32.zip
mv chrome-win32.zip chrome-win32__$ver.zip