Skip to content

Instantly share code, notes, and snippets.

@cacoco
cacoco / SmallyServer.scala
Last active August 29, 2015 14:24
SmallyServer
object SmallyServerMain extends SmallyServer
class SmallyServer extends HttpServer {
override def modules = Seq(
LogbackModule,
new JedisClientModule,
new SmallyModule)
override def configureHttp(router: HttpRouter) {
router.
@cacoco
cacoco / SmallyController.scala
Created July 13, 2015 03:31
SmallyController
class SmallyController @Inject()(
@Flag("secure") secure: Boolean,
urlShortenerService: RedisUrlShortenerService,
response: ResponseBuilder)
extends Controller
with Logging {
post("/url") { request: PostUrlRequest =>
val url = new URL(request.url)
val path = urlShortenerService.create(url)
@cacoco
cacoco / keybase.md
Created September 21, 2017 18:03
Keybase Proof

Keybase proof

I hereby claim:

  • I am cacoco on github.
  • I am cacoco (https://keybase.io/cacoco) on keybase.
  • I have a public key ASAPB5sfRnetgJ-AzzBsVVrvIF3Hsiz_irbWcVOgkJsHigo

To claim this, I am signing this object:

@cacoco
cacoco / export-google-docs-to-restructured-text.js
Last active June 1, 2021 19:33 — forked from simonw/export-google-docs-to-restructured-text.js
Google Apps script to convert a Google Docs document into reStructuredText
function onOpen() {
var ui = DocumentApp.getUi();
ui.createMenu('Convert to .RST')
.addItem('Convert to .RST and email me the result', 'ConvertToRestructuredText')
.addToUi();
}
// Adopted from https://github.com/mangini/gdocs2md by Renato Mangini
// License: Apache License Version 2.0
String.prototype.repeat = String.prototype.repeat || function(num) {
import com.twitter.finagle.{Http, ListeningServer, Service}
import com.twitter.finagle.http.{Status, Response, Request}
import com.twitter.server.TwitterServer
import com.twitter.util.{Await, Future}
class MyTwitterServer extends TwitterServer {
val defaultHttpPortValue: String = ":8888"
private val httpPortFlag =
flag("http.port", defaultHttpPortValue, "External HTTP server port")
private def responseString: String = "Hello, world!"
import com.twitter.inject.server.{EmbeddedTwitterServer, FeatureTest}
class MyTwitterServerFeatureTest extends FeatureTest {
override protected val server =
new EmbeddedTwitterServer(new MyTwitterServer)
test("MyTwitterServer#starts") {
server.isHealthy
}
import com.twitter.inject.server.{EmbeddedTwitterServer, FeatureTest}
class MyTwitterServerFeatureTest extends FeatureTest {
override protected val server =
new EmbeddedTwitterServer(new MyTwitterServer)
override protected def beforeAll(): Unit = {
server.start()
}
import com.twitter.inject.server.{EmbeddedTwitterServer, FeatureTest}
class MyTwitterServerFeatureTest extends FeatureTest {
override protected val server =
new EmbeddedTwitterServer(
twitterServer = new MyTwitterServer,
flags = Map(
“dtab.add” -> “/$/inet=>/$/nil;/zk=>/$/nil”)
)
import com.twitter.finagle.Http
import com.twitter.inject.server.{EmbeddedTwitterServer, FeatureTest}
import java.net.InetAddress
class MyTwitterServerFeatureTest extends FeatureTest {
override protected val server =
new EmbeddedTwitterServer(new MyTwitterServer)
lazy val client =