Skip to content

Instantly share code, notes, and snippets.

@ittaiz
ittaiz / .bazelproject
Created September 14, 2022 09:39
IJWB bazelproject file for repro
directories:
.
-aswb
-clwb
-cpp
targets:
//ijwb:ijwb_bazel_dev
//ijwb:ijwb_lib
//:ijwb_ce_tests
@ittaiz
ittaiz / scalafmt_repositories.bzl
Created January 16, 2020 14:05
scalafmt repositories
load(
"@io_bazel_rules_scala//scala:_scala_maven_import_external.bzl",
_scala_maven_import_external = "scala_maven_import_external",
)
def scalafmt_dependencies():
_scala_maven_import_external(
name = "org_scalameta_common_2_11",
artifact = "org.scalameta:common_2.11:4.2.0",
artifact_sha256 = "c2921b10ef2a06cafa48d4e0a6be4ff42c9135b5c5cf51ec3fdd9b66077f66cb",
srcjar_sha256 = "373ee3a734ae1ca8cb3361812f0702ed52d5d2fbff95e7406752be408a2d9a59",
@ittaiz
ittaiz / scalafmt_repositories.bzl
Created January 16, 2020 14:05
scalafmt repositories
load(
"@io_bazel_rules_scala//scala:_scala_maven_import_external.bzl",
_scala_maven_import_external = "scala_maven_import_external",
)
def scalafmt_dependencies():
_scala_maven_import_external(
name = "org_scalameta_common_2_11",
artifact = "org.scalameta:common_2.11:4.2.0",
artifact_sha256 = "c2921b10ef2a06cafa48d4e0a6be4ff42c9135b5c5cf51ec3fdd9b66077f66cb",
srcjar_sha256 = "373ee3a734ae1ca8cb3361812f0702ed52d5d2fbff95e7406752be408a2d9a59",
@ittaiz
ittaiz / config.bzl
Last active May 3, 2018 18:51
Bazel Skylark rule and aspect to collect all config files (erbs) transitively
ConfigFiles = provider(
fields = {
'transitive_config_files' : 'number of files'
}
)
_erb_filetype = FileType([".erb"])
_attrs = ['tars','deps','runtime_deps','exports'] #data?
def _accumulate_transitive_config_files(accumulated, deps):
return depset(
@ittaiz
ittaiz / scala_import.bzl
Created September 15, 2017 11:29
scala_import.bzl which allows to depend on maven jar //jar:file and have it recognized in intellij
def _scala_import_impl(ctx):
code_jars = _filter_out_non_code_jars(ctx.attr.jar.files)
code_jars_depset = depset(code_jars)
return struct(
scala = struct(
outputs = struct(
ijar = None,
class_jar = code_jars[0],
),
),
@ittaiz
ittaiz / FruitTest.scala
Last active July 28, 2016 12:56
Polymorphic matching
class FruitTest extends SpecificationWithJUnit {
trait Fruit
case class Apple(color: String) extends Fruit
case class Peach(ripeness: Double) extends Fruit
def aColorfulApple(color: String): Matcher[Fruit] = {
val appleMatcher: Matcher[Apple] = be_===(color) ^^ { a: Apple =>
a.color aka "apple color"
@ittaiz
ittaiz / pom.xml
Last active December 24, 2015 08:48
Specs2 uber pom
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.specs2</groupId>
<artifactId>specs2_2.11</artifactId>
<version>3.5</version>
<name>Specs2 includes</name>
<packaging>pom</packaging>
<dependencies>
<dependency>
@ittaiz
ittaiz / ShutdownAllowingDeterministicScheduler.java
Created December 19, 2015 20:58
ShutdownAllowingDeterministicScheduler suggestion to jmock
private class ShutdownAllowingDeterministicScheduler extends DeterministicScheduler {
override def isShutdown: Boolean = shutdownRequested
override def isTerminated: Boolean = shutdownRequested
override def shutdown(): Unit = shutdownRequested = true
override def shutdownNow: util.List[Runnable] = new util.ArrayList[Runnable]
var shutdownRequested: Boolean = false
@ittaiz
ittaiz / gist:e4dd2efba31757fe4073
Created March 22, 2015 19:45
Maven polyglot scala build failure
Apache Maven 3.3.1 (cab6659f9874fa96462afef40fcf6bc033d58c1c; 2015-03-13T22:10:27+02:00)
Maven home: /usr/local/Cellar/maven/3.3.1/libexec
Java version: 1.7.0_71, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
[DEBUG] Reading global settings from /usr/local/Cellar/maven/3.3.1/libexec/conf/settings.xml
[DEBUG] Reading user settings from /Users/ittaiz/.m2/settings.xml
[DEBUG] Using manager EnhancedLocalRepositoryManager with priority 10.0 for /Users/ittaiz/.m2/repository
[DEBUG] Dependency collection stats: {ConflictMarker.analyzeTime=1, ConflictMarker.markTime=0, ConflictMarker.nodeCount=20, ConflictIdSorter.graphTime=0, ConflictIdSorter.topsortTime=1, ConflictIdSorter.conflictIdCount=11, ConflictIdSorter.conflictIdCycleCount=0, ConflictResolver.totalTime=3, ConflictResolver.conflictItemCount=19, DefaultDependencyCollector.collectTime=125, DefaultDependencyCollector.transformTime=6}
[DEBUG] io.takari.poly
@ittaiz
ittaiz / JacksonRegressionTest.java
Created March 13, 2015 20:29
Jackson Custom exception regression issue
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.scala.DefaultScalaModule;
import org.junit.Test;
import java.io.IOException;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
public class JacksonRegressionTest {
@Test
public void jacksonRegressionTest() throws IOException {
SomeException ex = new SomeException("message");