Skip to content

Instantly share code, notes, and snippets.

View devshorts's full-sized avatar

Anton Kropp devshorts

View GitHub Profile
// finagle 6.1.33
class ClientObjectTests extends FlatSpec with Matchers with BeforeAndAfterAll {
"A client" should "be closeable" in {
val client =
ClientBuilder()
.dest("localhost:1")
.codec(Http())
.hostConnectionLimit(1)
.build()
@RunWith(classOf[JUnitRunner])
class ClientObjectTests extends FlatSpec with Matchers with BeforeAndAfterAll {
"A client" should "be closeable" in {
val client =
ClientBuilder()
.dest("localhost:1")
.codec(Http())
.hostConnectionLimit(1)
.build()
package tests
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.finagle.http.Http
import com.twitter.finatra.httpclient.RequestBuilder
import com.twitter.util.{Await, Future}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers}
case class StringAnyVal @JsonCreator()(@(JsonValue@getter) value: String) extends AnyVal
case class AnyValHolder(anyVal: StringAnyVal)
class Jackson extends FlatSpec with Matchers {
val finatra = FinatraObjectMapper.create().objectMapper
val jackson = {
val o = new ObjectMapper with ScalaObjectMapper
o.registerModule(DefaultScalaModule)
object BitGroup {
def zero(max: Int): BitGroup = {
val bytesRequired = max / 8
new BitGroup(new Array[Byte](bytesRequired + 1), max)
}
def filled(max: Int): BitGroup = {
val bytesRequired = max / 8
trait BigIntegerTypesComponent extends RelationalTypesComponent {
self: JdbcProfile =>
implicit def bigIntType = new BigIntegerJdbcType
implicit val bigIntSetParam = new SetParameter[BigInteger] {
override def apply(v1: BigInteger, v2: PositionedParameters): Unit = v2.setObject(v1, java.sql.Types.BIGINT)
}
class BigIntegerJdbcType extends DriverJdbcType[BigInteger] with NumericTypedType {
object EditDistance {
def within(s1: String, s2: String, n: Int = 1): Boolean = {
if (s1 != s2 && Math.abs(s1.length - s2.length) > 1) {
return false
}
var s1Idx = 0
var s2Idx = 0
def withinN() = Math.abs(s1Idx - s2Idx) <= n
/**
* Encoding for "A is not a subtype of B"
* @note original credit: https://gist.github.com/milessabin/c9f8befa932d98dcc7a4
*/
trait NotTypeOf[A, B]
trait NotTypeImplicits {
// Uses ambiguity to rule out the cases we're trying to exclude
implicit def allowedType[A, B] : A NotTypeOf B = null
implicit def typeSuperTypeOfInvalid[A, B >: A] : A NotTypeOf B = null
#!/usr/bin/env ruby
require 'octokit'
require 'pp'
Octokit.auto_paginate = true
org=ARGV[0]
client = Octokit::Client.new(:access_token => "#{ENV['GIT_ACCESS_TOKEN']}")
@devshorts
devshorts / zip.go
Created August 29, 2018 16:44
golang zip
package packaging
import (
"archive/zip"
"io"
)
type PackageContents struct {
Data io.Reader
FileName string