This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<configuration> | |
<archive> | |
<manifest> | |
<mainClass>org.webcrawler.core.Driver</mainClass> | |
</manifest> | |
</archive> | |
<descriptorRefs> | |
<descriptorRef>jar-with-dependencies</descriptorRef> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SOME_STRING="exit 0" | |
PATH_TO_YOUR_FILE="./file" | |
cat $PATH_TO_YOUR_FILE | head -n `expr $(echo $(cat -n $PATH_TO_YOUR_FILE | grep "$SOME_STRING" | tail -n 1) | cut -d ' ' -f 1) - 1` > $PATH_TO_YOUR_FILE | |
echo -e "Hello world\n$SOME_STRING" >> $PATH_TO_YOUR_FILE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# cache password rather retyping if not using SSH key | |
git config --global credential.helper cache | |
# local revert head upto x (number of last commit) | |
git reset --hard HEAD~x | |
# take remote head to x (commit hash) and remove commits after x (commit hash) | |
git push origin +x:IM-213 | |
# clear contents of stash stack (https://git-scm.com/docs/git-stash) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependencies> | |
<dependency> | |
<groupId>org.scala-lang</groupId> | |
<artifactId>scala-library</artifactId> | |
<version>${scala.version}</version> | |
</dependency> | |
<!-- APACHE SPARK --> | |
<dependency> | |
<groupId>org.apache.spark</groupId> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# disabling second argument if "push" else works as it is | |
block_git_push() { | |
if [ $1 = "push" ]; then | |
echo "\"push\" is blocked temporarily in ~/.bashrc file to prevent volcano eruption." | |
else | |
git $* | |
fi | |
} | |
alias git=block_git_push |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class ScreenSaver { | |
public static final void main(final String[] args) throws Exception { | |
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); | |
final JFrame screenSaverFrame = new JFrame(); | |
screenSaverFrame.setDefaultCloseOperation( | |
WindowConstants.EXIT_ON_CLOSE); | |
screenSaverFrame.setUndecorated(true); | |
screenSaverFrame.setResizable(false); | |
screenSaverFrame.add(new JLabel("This is a Java Screensaver!", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(args: Any*) = { | |
args.flatMap { | |
case str: String if str.isEmpty => None | |
case str: String => Some(str) | |
case Some(x: String) if x.isEmpty => None | |
case Some(x: String) => Some(x) | |
}.mkString(", ") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val thisfile = sc.textFile("/home/fahad/e.json") | |
thisfile: org.apache.spark.rdd.RDD[String] = /home/fahad/e.json MapPartitionsRDD[102] at textFile at <console>:27 | |
scala> val rdd = sc.parallelize((thisfile.collect().mkString.replace("},", "}}\n{").dropRight(1) + "}").split("\n")) | |
rdd: org.apache.spark.rdd.RDD[String] = ParallelCollectionRDD[103] at parallelize at <console>:29 | |
scala> val xy = sqlContext.read.json(rdd) | |
xy: org.apache.spark.sql.DataFrame = [emp-1: struct<age:bigint,name:string,sex:string>, emp-2: struct<age:bigint,name:string,sex:string>] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// startDate, endDate are jodatime LocalDate objects | |
val daysCount = Days.daysBetween(startDate, endDate).getDays | |
(0 until daysCount).map(startDate.plusDays).foreach { today => | |
// today is LocalDate | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def foo(l: List[Any]): List[Int] = { | |
l flatMap { | |
case e: Int => List(e) | |
case f: List[Any] => foo(f) | |
} | |
} | |
foo(List(1, List(1, 3, List(1, 7, List(3, 5, 7))))) // results List(1, 1, 3, 1, 7, 3, 5, 7) |
OlderNewer