Skip to content

Instantly share code, notes, and snippets.

View sarveshseri's full-sized avatar

Sarvesh Kumar Singh sarveshseri

View GitHub Profile
import scala.collection.mutable.Stack
case class Tower(name: String, disks: Stack[Int])
case class TohState(src: String, tgt: String, tmp: String)
case class TohStep(move: String, before: TohState, after: TohState)
object LazyToh {
val srcName = "SRC"
@sarveshseri
sarveshseri / UniqueItemIDGen.scala
Last active March 25, 2016 02:20
Unique Id generator for models in Scala applications
import org.joda.time.DateTime
import scala.annotation.tailrec
import scala.util.Random
object RANStream {
val randomAlphaNumIterator = Random.alphanumeric.iterator
@tailrec
def getRandomString(length: Int, acc: String = ""): String = {

Fix corrupt file system

First of all switch to the hdfs user

sudo su hdfs
Check file system health
hdfs -fsck /
# or
hdfs fsck hdfs://hdfsHost:port/

Lets assume that you have a cluster with the name - awesome_cluster.

How to enable a HDFS View

On a fresh Ambari cluster, we need to follow following steps to create the HDFS view.

Allow the superuser to impersonate other users.

Well... Ambari tries to impersonate the current logged in user with the superuser, and thus the simplest ( but not the best ) thing is to allow the superuser to imperonate all users. Similarily we also need to tell Ambari the name of the host from which the superuser can connect ( simplest is to allow all hosts ).

On Ambari dashboard go to Services > HDFS > Config > Advanced > Custom Core Site and add following new paramters

@sarveshseri
sarveshseri / ec2-ubuntu-prepare.md
Last active October 23, 2015 08:37
Prepare ec2 instances
Initial upgrade
sudo apt-get update
sudo apt-get -y upgrade
Install essentials
sudo apt-get install -y build-essential
sudo apt-get install -y git

Install Homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Setup zsh

Install zsh
$ brew install zsh
oh-my-zsh

tl;dr

  1. Don't run as root.
  2. For sessions, set httpOnly (and secure to true if running over SSL) when setting cookies.
  3. Use the Helmet for secure headers: https://github.com/evilpacket/helmet
  4. Enable csrf for preventing Cross-Site Request Forgery: http://expressjs.com/api.html#csrf
  5. Don't use the deprecated bodyParser() and only use multipart explicitly. To avoid multiparts vulnerability to 'temp file' bloat, use the defer property and pipe() the multipart upload stream to the intended destination.

Arch KDE

Remove all xfce4
sudo su -
pacman -Sg xfce4 xfce4-goodies | awk '{print $2}' | xargs pacman -R --noconfirm libxfce4ui libxfcegui4
Install KDE

Arch Gnome

Remove all xfce4
sudo su -
pacman -Sg xfce4 xfce4-goodies | awk '{print $2}' | xargs pacman -R --noconfirm libxfce4ui libxfcegui4

Network Manager