Skip to content

Instantly share code, notes, and snippets.

View jkschneider's full-sized avatar

Jonathan Schnéider jkschneider

View GitHub Profile
@jkschneider
jkschneider / README.md
Created February 7, 2013 16:46
D3 Beeswarm Layout

The beeswarm visualization is used to plot highly compact single-dimensional data by allowing data points to be pushed off the principal axis of the data along the normal to that axis. This visualization can be especially useful for time-series data, maintaining the visual ordering of the data points while allowing for localized regions of highly compact data in the view.

Other implementations use force layout, but the force layout simulation naturally tries to reach its equilibrium by pushing data points along both axes, which can be disruptive to the ordering of the data.

This implementation could be improved by replacing the normally distributed random jittering with an intelligent strategy. For my purpose, this sufficed. The total number of iterations over the collision visitor directly affects the probability of collisions in the end state.

@jkschneider
jkschneider / README.md
Created February 7, 2013 22:38
D3 Beeswarm Layout with Zooming, Axis

##Introduction##

The beeswarm visualization is used to plot highly compact single-dimensional data by allowing data points to be pushed off the principal axis of the data along the normal to that axis. This visualization can be especially useful for time-series data, maintaining the visual ordering of the data points while allowing for localized regions of highly compact data in the view.

Other implementations use force layout, but the force layout simulation naturally tries to reach its equilibrium by pushing data points along both axes, which can be disruptive to the ordering of the data.

This implementation could be improved by replacing the normally distributed random jittering with an intelligent strategy. For my purpose, this sufficed. The total number of iterations over the collision visitor directly affects the probability of collisions in the end state.

##Zooming## To get zooming to work correctly, I have followed some of the great advice here http://bit.ly/14W6TF7.

@jkschneider
jkschneider / README.md
Last active July 14, 2019 19:34
Dependency Tree

About

This is a simple demonstration of the use of a constraint-based force layout to represent the dependency hierarchy. Subgraphs are not repeated as they are in the console rendering. As a result, we don't have to make any special provision for dependency cycles.

The Floyd-Warshall algorithm is used to display relative path distances. Floyd-Warshall has been extended with path reconstruction as well to show the shortest path solutions between nodes.

It is possible the display could be improved further through hierarchical grouping to highlight the commonly repeated subgraphs (e.g. the subgraph including the path L->I->O->P->Q).

How to use

@jkschneider
jkschneider / GloomFilter.groovy
Last active August 29, 2015 14:11
Opposite of a bloom filter... reports "not in set" whenever multiset reports 0 or >1.
/**
* The opposite of a bloom filter
*/
class GloomFilter<T> {
Multiset<Long> coordinateFilter
Funnel<T> funnel
long expectedSize
static create(int expectedSize, Funnel<T> funnel) {
return new GloomFilter<T>(expectedSize: expectedSize,
@jkschneider
jkschneider / build.groovy
Last active September 17, 2015 23:32
Alteration to default behavior of nebula-publish (and indeed Gradle's maven-publish behavior) to produce compile scoped dependencies in the POM
publishing {
publications {
nebula(MavenPublication) {
pom.withXml {
configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each { dep ->
asNode().dependencies[0].dependency.find {
it.artifactId[0].text() == dep.moduleName &&
it.groupId[0].text() == dep.moduleGroup
}.scope[0].value = 'compile'
}
@jkschneider
jkschneider / debian.kt
Last active October 13, 2015 04:31
Grab control file info and war dependencies from a debian file
package com.netflix.debian
import org.apache.commons.compress.archivers.*
import org.apache.commons.compress.compressors.CompressorStreamFactory
import java.io.*
fun main(args: Array<String>) {
val libPattern = "WEB-INF/lib/(.+)\\.jar".toRegex()
FileInputStream("pisces.deb").archiveStream { entry, debIn ->
@jkschneider
jkschneider / MyService.kt
Created October 27, 2015 16:47
Differentiating between local and cloud deployments (Spring Boot)
@SpringBootApplication
open class MyService: SpringBootServletInitializer() {
companion object {
// used for local development only
@JvmStatic fun main(args: Array<String>) {
SpringApplicationBuilder(MyService::class.java).profiles("local").run(*args)
}
}
// only executes when running inside of Tomcat standalone -- which only occurs in the
@Test fun toSortedMap_comparator() {
val expected = mapOf("c" to 6, "a" to 4, "b" to 2, "d" to 0)
val actual = original.toSortedMap(comparator { x, y -> (original[y] as Int).compareTo((original[x] as Int)) })
assertOrder(expected, actual)
}
@jkschneider
jkschneider / build.gradle
Created May 31, 2016 22:41
Gradle First Level Dependency Subgraph Size
task firstLevelSubgraphSize << {
def cardinality = { ResolvedDependency d, Set<ModuleVersionIdentifier> alreadySeen ->
alreadySeen.add(d.module.id) ? d.children.sum(0) { owner.call(it, alreadySeen) } + 1 : 0
}
configurations.compile.resolvedConfiguration.firstLevelModuleDependencies.each {
println it.module.id.toString() + ' -> ' + cardinality(it, [] as Set)
}
}
@jkschneider
jkschneider / main.kt
Last active October 3, 2016 17:46
InterceptorConfig Kotlin example
package com.sazzad
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.builder.SpringApplicationBuilder
import org.springframework.context.annotation.ComponentScan
import org.springframework.context.annotation.Configuration
import org.springframework.stereotype.Component
import org.springframework.web.servlet.HandlerInterceptor
import org.springframework.web.servlet.ModelAndView