Skip to content

Instantly share code, notes, and snippets.

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 =
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.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(new MyTwitterServer)
test("MyTwitterServer#starts") {
server.isHealthy
}
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!"
@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) {
@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 / 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 / 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.
[Tue May 12 11:33:31 ccoco@horus finatra-hello-world (master)]$ ../../sbt clean test
downloading sbt-launch.jar from http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.13.8/sbt-launch.jar
[info] Loading project definition from /Users/ccoco/github/twitter/finatra/examples/finatra-hello-world/project
[info] Updating {file:/Users/ccoco/github/twitter/finatra/examples/finatra-hello-world/project/}finatra-hello-world-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to finatraHelloWorld (in build file:/Users/ccoco/github/twitter/finatra/examples/finatra-hello-world/)
[success] Total time: 0 s, completed May 12, 2015 11:34:00 AM
[info] Updating {file:/Users/ccoco/github/twitter/finatra/examples/finatra-hello-world/}finatraHelloWorld...
[info] Resolving jline#jline;2.12.1 ...