Skip to content

Instantly share code, notes, and snippets.

View arschles's full-sized avatar
🎯
Focusing

Aaron Schlesinger arschles

🎯
Focusing
View GitHub Profile
@arschles
arschles / app_fmwk.md
Last active August 21, 2019 13:01
Vecty/GopherJS Web App Framework

Web App Framework with Vecty & GopherJS

This document describes a web app framework targeted for Vecty & GopherJS.

Goals:

  • Go is the primary language for all frontend and backend tasks. An app developer should be able to write full-feaured web applications using only Go and without any HTML/Javascript/CSS knowledge or expertise
  • The framework handles and compiles Go code targeting the frontend and backend
    • Framework can build frontend code into HTMl/JS/CSS or Web Assembly (WASM). In both cases, the resulting app is a SPA
  • Framework design might enable classic web apps with multiple routes, but that's not a design goal
@arschles
arschles / get_with_retry.go
Last active April 15, 2019 20:27
GetWithRetry
package main
import (
"context"
"fmt"
"time"
)
// adaptation of
// https://github.com/Azure/aks-engine/blob/f61205726c139d286c427b3403942a079eb1b26d/test/e2e/kubernetes/pod/pod.go#L289
@arschles
arschles / westeurope.sh
Last active April 3, 2019 22:53
Testing Athens /list endpoints
az container create \
--resource-group remotedesktop \
--name athenstesteu \
--image gomods/athens:canary \
--restart-policy OnFailure \
--location westeurope
# apk add -U curl
# time curl athens-westeurope.westeurope.azurecontainer.io:3000/cloud.google.com/go/@v/list
az container exec -g remotedesktop -n athenstesteu --exec-command ash
@arschles
arschles / log_entry.go
Last active September 11, 2018 20:51
Threading Log Entries Down the Stack in Athens
func newLogEntry(req *http.Request, lggr *log.Logger) logrus.Entry {
return lggr.WithFields(logrus.Fields{
"http-method": req.Method,
"http-path": req.URL.Path,
"http-url": req.URL.String(),
})
}
@arschles
arschles / scalaConcurrentPatterns.scala
Last active August 23, 2018 15:00
examples of common concurrency patterns that you can achieve with the scala.concurrent package
import scala.concurrent._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.util.Random
import java.util.{Timer, TimerTask}
object Util {
sealed trait BaseResponse
case class Response1(res: Int) extends BaseResponse
case class Response2(res: String) extends BaseResponse
@arschles
arschles / athens-tests.sh
Created August 15, 2018 00:45
Running athens tests
#!/bin/sh
make dev-teardown
export GO_BINARY_PATH=go1.11rc1
make alldeps
# sleep a little more
sleep 5
buffalo db create
buffalo db migrate up
make test-unit
@arschles
arschles / buffalo_actions_test.go
Last active July 10, 2018 16:42
Sample Buffalo Test
package actions
// this is a test method. It needs to have the prefix "Test"
func (a *ActionSuite) TestSomething() {
// this gives you one of these: https://godoc.org/github.com/stretchr/testify/require#Assertions
//
// you can also use a.Assert() to get one of these: https://godoc.org/github.com/stretchr/testify/assert#Assertions
r := a.Require()
// this gets you a completely empty DB with all the schemas and migrations already run on it.
@arschles
arschles / demo.sh
Last active May 18, 2018 00:14
Cloud Native PDX May 17 2018 Demo Commands
#!/bin/bash
echo "OSBA (the broker for Azure) and service-catalog (the adapter for Kubernetes) are installed:"
helm list
echo "we also have a cool catalog of services we can create and hook up to:"
kubectl get clusterserviceclasses
echo "that's lame ... let's use svcat to see a friendly version:"
svcat get classes
@arschles
arschles / twitterFutureToScala.scala
Created May 2, 2013 18:45
Converting a Twitter future to a Scala Future
import com.twitter.util.{Future => TwFuture}
import scala.concurrent.{Future => ScFuture, promise => scPromise}
implicit def twFutureToScala[T](twFuture: TwFuture[T]): ScFuture[T] = {
val prom = scPromise[T]
twFuture.onComplete { res: T =>
prom.success(res)
}
twFuture.onFailure { t: Throwable =>
prom.failure(t)
}
@arschles
arschles / gist:2288158
Created April 3, 2012 00:06
Scala PhoneGap Build Client
val BaseBuildURL = "https://build.phonegap.com/api/v1"
val UTF8Charset = Charset.forName("UTF-8")
case class MultipartInfo(contentType: Header, contentEncoding: Option[Header])
val baseHeaders: List[Header] = {
val authRaw = "%s:%s".format(phoneGapCreds.username, phoneGapCreds.password)
val authBase64 = Base64.encodeBase64(authRaw.getBytes(UTF8Charset))
val authString = new String(authBase64, UTF8Charset)
List(
new BasicHeader(HttpHeaders.AUTHORIZATION, "Basic %s".format(authString)),
new BasicHeader(HttpHeaders.ACCEPT, "*/*"),