Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View fkautz's full-sized avatar

Frederick F. Kautz IV fkautz

View GitHub Profile
@fkautz
fkautz / Calculator.scala
Last active December 18, 2015 21:19
Example of compiler discovering and warning missing cases in a simple calculator. sealed abstract class Expression is required for the warning message to appear. Sealed will require all direct subclasses (but not subclasses of subclasses) to be defined within the same file.
sealed abstract class Expression
case class Add(val exp1:Expression, val exp2:Expression) extends Expression
case class Subtract(val exp1:Expression, val exp2:Expression) extends Expression
case class Multiply(val exp1:Expression, val exp2:Expression) extends Expression
case class Divide(val exp1:Expression, val exp2:Expression) extends Expression
case class Value(value:Double) extends Expression
object Calculator {
def calculate(expression:Expression):Double = {
@fkautz
fkautz / DynamicDispatchCalculator.scala
Last active December 18, 2015 21:19
Simple calculator using dynamic dispatch.
package dynamic
abstract class Expression {
def eval:Double = ???
}
case class Value(val value: Double) extends Expression {
override def eval = value
}
object Chaining {
val xs = List(1,2,3,4,5) //> xs : List[Int] = List(1, 2, 3, 4, 5)
def square(x:Int):Int = x*x //> square: (x: Int)Int
def even(x:Int):Boolean = x%2 == 0 //> even: (x: Int)Boolean
//// SHORT EXAMPLE
xs map square // <-- Prefer //> res0: List[Int] = List(1, 4, 9, 16, 25)
// vs
xs.map(square) //> res1: List[Int] = List(1, 4, 9, 16, 25)
@fkautz
fkautz / serverdemo.go
Created January 31, 2014 07:33
A simple demo of mixing various go http server and rpc using mux
package main
import (
"bytes"
"fmt"
"github.com/gorilla/mux"
grpc "github.com/gorilla/rpc"
"github.com/gorilla/rpc/json"
"log"
"net/http"
<section data-background-transition='zoom' data-transition='concave' data-background='http://ryanjarvinen.com/presentations/shared/img/broadcast_reveal_dark.png' data-state='blackout'>
<h2>roadcasting Your</h3>
<h1>eveal.js</h1>
<h2>lideshow Presentations</h2>
<h1>LIVE</h1>
<p>on</p>
<img style="disply:block;border:none;background:none;box-shadow:none;width:50%;" alt='Docker-logo' src='https://gist.githubusercontent.com/ryanj/7ebf56442930b4c2188b/raw/6a6e03247efb03a0eee24a12f7beaf1ab4634563/Docker-whale.png'/>
<p class='fragment'><small><a href='http://dockercon-slides.com/'>dockercon-slides.com</a><br/>
<a href='http://github.com/ryanj/gist-reveal.it'>github.com/ryanj/gist-reveal.it</a></small></p>
</section>
@fkautz
fkautz / probcalc.go
Created February 10, 2015 23:37
Simple Probability Calculator
package main
import (
"fmt"
)
func main() {
fmt.Println("Prob 12 (P=0.02): ", findProb(0.02, 12))
fmt.Println("Prob 24 (P=0.02): ", findProb(0.02, 24))
fmt.Println()

Keybase proof

I hereby claim:

  • I am fkautz on github.
  • I am fkautz (https://keybase.io/fkautz) on keybase.
  • I have a public key ASAVFqI73t8aycbbfmHjvA9YZN_Fnhkq9K3Bzd4E-UbrOgo

To claim this, I am signing this object:

@fkautz
fkautz / gist:1b0f5c545d0995b5274f997da3fe72f6
Last active August 1, 2018 18:19
binding privileged container to netns of unprivileged container
$ kubectl get pods
NAME                      READY     STATUS        RESTARTS   AGE
nginx-56f766d96f-lxkc9    1/1       Running       0          6m
$ docker ps | grep k8s_POD_nginx-56f766d96f-lxkc9
85b59aced967        k8s.gcr.io/pause-amd64:3.1   "/pause"                 7 minutes ago       Up 7 minutes                            k8s_POD_nginx-56f766d96f-lxkc9_default_426a6401-95b5-11e8-8a83-0800271b7911_0
@fkautz
fkautz / x-factor-cnfs.md
Created August 24, 2018 07:17
X-Factor CNFs

The community is currently in the process of defining Cloud-Native Network Functions (CNFs). Due to the differences between the current modern architecture and cloud-native environment, many questions will arise about how to create, consume, operate, monitor and scale CNFs. As CNFs gain in popularity, it will become increasingly important to have a set of guidelines to help the community maximize the benefit received from running in the new Cloud-Native environment.

When cloud-native arrived, it was often unclear how web applications should be designed or rearchitected to make use of cloud-native infrastructure. Many mistakes were repeated due to a lack of guidance. In response, Adam Wiggins and others created a methodology known as 12 Factor Apps. 12 factor apps guide developers towards building applications capable of taking advantage of cloud-native infrastructure. These properties include but are not limited to:

  • Easier on-boarding for developers
  • Maximize portability
  • Deploy on modern cloud platfor