Skip to content

Instantly share code, notes, and snippets.

View dwalend's full-sized avatar

David Walend dwalend

View GitHub Profile
@dwalend
dwalend / Bootstrap.scala
Created September 18, 2018 20:48
AsyncHttp4sServlet is not async
package net.shrine.api
import cats.effect.{ConcurrentEffect, IO}
import javax.servlet.annotation.WebListener
import javax.servlet.{ServletContextEvent, ServletContextListener}
import net.shrine.api.http4s.servlet.syntax.ShrineServletContextSyntax
import org.http4s.HttpRoutes
import org.http4s.dsl.impl.{->, /}
import org.http4s.dsl.io.{GET, Ok, Root, http4sOkSyntax}
@dwalend
dwalend / Http4sClientTest.scala
Last active June 21, 2021 16:02
http4s client that can work through a client-side https proxy
package net.shrine.utilities.http4sclienttest
import cats.effect.IO
import io.netty.handler.ssl.{SslContext, SslContextBuilder}
import org.asynchttpclient.Dsl
import org.asynchttpclient.netty.ssl.InsecureTrustManagerFactory
import org.asynchttpclient.proxy.ProxyServer
import org.http4s.client.Client
import org.http4s.client.asynchttpclient.AsyncHttpClient
import org.http4s.headers.Accept
package net.shrine
import com.typesafe.config.Config
package object config {
/**
* @author dwalend
* @since July 17, 2015
*
@dwalend
dwalend / pre-render.js
Last active August 29, 2015 14:27 — forked from mef/pre-render.js
proof-of-concept pre-rendering d3.js svgs on the server using node.js and jsdom module.
// pre-render d3 charts at server side
var d3 = require('d3')
, jsdom = require('jsdom')
, fs = require('fs')
, htmlStub = '<html><head></head><body><div id="dataviz-container"></div><script src="js/d3.v3.min.js"></script></body></html>'
jsdom.env({
features : { QuerySelector : true }
, html : htmlStub
, done : function(errors, window) {
@dwalend
dwalend / AtomicConfigSource.scala
Last active March 2, 2017 15:13
Typesafe-Config with custom Configs for unit testing
import java.util.concurrent.atomic.AtomicReference
import scala.util.{Failure, Success, Try}
import com.typesafe.config.{Config, ConfigFactory}
/**
Use to tweak a Config without clearing and reloading a new config (for testing).
@author dwalend
*/
class AtomicConfigSource(baseConfig:Config) {
val atomicConfigRef = new AtomicReference[Config](ConfigFactory.empty())
@dwalend
dwalend / InnerObjectVisibiltiy.Scala
Created June 5, 2015 02:26
Code for a blog entry about inner objects and inner traits. This won't compile, but I think maybe it should.
trait TopTrait {
def topDef:String
}
trait BeyondTrait {
def innerThing:InnerTrait
trait InnerTrait extends TopTrait{
def innerDef = "innerDef"