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 org.json4s._ | |
import org.json4s.jackson.JsonMethods.parse | |
import scala.io.Source.fromURL | |
object SparkAppStats { | |
/** | |
* (partial) representation of a Spark Stage object | |
*/ | |
case class SparkStage(name: String, shuffleWriteBytes: Long, memoryBytesSpilled: Long, diskBytesSpilled: Long) |
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 class StaticClass { | |
static { | |
throwsException(); | |
} | |
private static void throwsException() { | |
throw new RuntimeException("bam!"); | |
} |
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 class UserValidator { | |
private Cryptographer cryptographer; | |
public boolean checkPassword(String userName, String password) { | |
User user = UserGateway.findByName(userName); | |
if (user != User.NULL) { | |
String codedPhrase = user.getPhraseEncodedByPassword(); | |
String phrase = cryptographer.decrypt(codedPhrase, password); | |
if ("Valid Password".equals(phrase)) { | |
Session.initialize(); |
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 com.codahale.metrics.MetricRegistry; | |
import io.dropwizard.db.DataSourceFactory; | |
import io.dropwizard.jackson.Jackson; | |
import io.dropwizard.jdbi.DBIFactory; | |
import io.dropwizard.setup.Environment; | |
import liquibase.Liquibase; | |
import liquibase.database.jvm.JdbcConnection; | |
import liquibase.exception.LiquibaseException; | |
import liquibase.resource.ClassLoaderResourceAccessor; | |
import org.junit.rules.ExternalResource; |
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
local ret_status="%(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ %s)" | |
PROMPT='⌚ %{$fg_bold[red]%}%*%{$reset_color%} ${ret_status}%{$fg_bold[green]%}%p %{$fg[cyan]%}%c %{$fg_bold[blue]%}$(git_prompt_info)%{$fg_bold[blue]%} % %{$reset_color%}' | |
ZSH_THEME_GIT_PROMPT_PREFIX="git:(%{$fg[red]%}" | |
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗%{$reset_color%}" | |
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})" |
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 class Spiderman { | |
public int spiderman(int n) { | |
// we're going to calculate these for each floor, starting from first floor: | |
int waysToGetToThisFloorByJumpingTwoFloors = 0; // there's no -1 floor, so there's no way to jump two floors and get to first floor | |
int waysToGetToThisFloorDirectlyFromPreviousFloor = 1; // there's one way to get from 0 to 1 | |
int totalWaysToGetToThisFloor = 0; | |
for (int floor=1; floor <= n; floor++) { | |
// total ways = sum of ways ending with a big jump (2 floors) and ways ending with a small jump (1 floor): |
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
package com.kenshoo.rtb.tools; | |
import org.junit.Test; | |
import static junit.framework.Assert.assertTrue; | |
import static org.mockito.Mockito.mock; | |
import static org.mockito.Mockito.when; | |
/** | |
* Created by IntelliJ IDEA. |
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 ch.qos.logback.classic.Level; | |
import com.kenshoo.test.LogbackVerifier; | |
import org.junit.Rule; | |
import org.junit.Test; | |
public class MyTest { | |
@Rule | |
public LogbackVerifier logbackVerifier = new LogbackVerifier(); |
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
package com.kenshoo.test; | |
import ch.qos.logback.classic.Level; | |
import ch.qos.logback.classic.Logger; | |
import ch.qos.logback.classic.spi.ILoggingEvent; | |
import ch.qos.logback.classic.spi.IThrowableProxy; | |
import ch.qos.logback.core.Appender; | |
import org.junit.rules.TestRule; | |
import org.junit.runner.Description; | |
import org.junit.runners.model.Statement; |
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
# sets up a dropwizard-based service packaged as debian | |
# requires: puppetlabs-apt, puppetlabs-stdlib | |
class sample-dw-service ( | |
$version='latest', # you can pass a specified version, default is latest | |
$db_url='' # this is how you pass environment-specific configuration - in this case, a DB URL | |
) { | |
# refresh apt | |
notify { "refreshing apt": | |
notify => Class['apt::update'], |