This file contains hidden or 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
Mockito.doReturn("fake hi", null.asInstanceOf[Array[Object]]: _* ) | |
when(t.get()).thenReturn("a", Array[Object](): _*) | |
v.overloadedMethod(arg0, null.asInstanceOf[Array[Object]]: _*) |
This file contains hidden or 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
val hadoopConf = spark.sparkContext.hadoopConfiguration | |
hadoopConf.addResource(new Path("D:\\src\\intellij\\conf\\core-site.xml")) | |
val path = new Path("sample.csv") | |
val fs = path.getFileSystem(hadoopConf) | |
println(fs.open(path).available()) | |
fs.close() |
This file contains hidden or 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
val dagScheduler = classOf[SparkContext].getDeclaredMethod("dagScheduler").invoke(sc) | |
val stageIdToStage = classOf[DAGScheduler].getDeclaredField("stageIdToStage").get(dagScheduler).asInstanceOf[HashMap[Int, Stage]] | |
val stage = stageIdToStage(stageInfo.stageId) |
This file contains hidden or 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
DateTimeFormatter timeFormatter = DateTimeFormatter.ISO_DATE_TIME; | |
TemporalAccessor accessor = timeFormatter.parse("2015-10-27T16:22:27.605-07:00"); | |
Date date = Date.from(Instant.from(accessor)); | |
System.out.println(date); |
This file contains hidden or 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
boolean tryParseInt(String value) { | |
try { | |
Integer.parseInt(value); | |
return true; | |
} catch (NumberFormatException e) { | |
return false; | |
} | |
} |
This file contains hidden or 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
Task.Backgroundable checkSshCertBackgroundTask = new Task.Backgroundable( | |
submitModel.getProject(), "Verify Authentication...", false) { | |
@Override | |
public void run(@NotNull ProgressIndicator indicator) { | |
try { | |
sleep(20 * 1000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} |
This file contains hidden or 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
Optional.of(new Outer()) | |
.map(Outer::getNested) | |
.map(Nested::getInner) | |
.map(Inner::getFoo) | |
.ifPresent(System.out::println); |
This file contains hidden or 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
import java.util.concurrent.Phaser; | |
// Main thread | |
// Reset the debug process Phaser | |
debugProcessPhaser = new Phaser(1); | |
new Thread(() -> { | |
// new debug process start | |
debugProcessPhaser.register(); |
This file contains hidden or 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
/** | |
* Retry observable subscription if timeout. | |
* | |
* For every retry it will wait delay + delayAmount so we wait more and more every retry. | |
* | |
* @param maxRetries number of retries | |
* @param delay milliseconds of wait between each try | |
* @param delayAmount delay + delayAmount | |
*/ | |
class RetryAfterTimeoutWithDelay(val maxRetries: Int, var delay: Long, val delayAmount: Long = 100) |
This file contains hidden or 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 enum UserStatus { | |
PENDING, | |
ACTIVE, | |
INACTIVE, | |
DELETED; | |
} | |
public enum WhoisRIR { | |
ARIN("whois.arin.net"), | |
RIPE("whois.ripe.net"), |