Skip to content

Instantly share code, notes, and snippets.

View noahlz's full-sized avatar
🕵️‍♂️
Secret Stuff for SEI Novus. I might take 1 - 3 days to respond.

Noah Zucker noahlz

🕵️‍♂️
Secret Stuff for SEI Novus. I might take 1 - 3 days to respond.
View GitHub Profile
@noahlz
noahlz / NotForYour.scala
Last active August 29, 2015 13:56
Learning about Scala's for comprehensions.
// See http://stackoverflow.com/questions/1052476/what-is-scalas-yield/1059501#1059501
// Compilation error is:
// [error] found : Seq[String]
// [error] required: Option[?]
// [error] child <- foo.children
// [error] ^
// [error] one error found
def divBy3(x: Int) = x % 3 == 0
// divBy3: (x: Int)Boolean
def divBy5(x: Int) = x % 5 == 0
// divBy5: (x: Int)Boolean
def divByAll(fns: List[(Int => Boolean)])(x: Int) = fns.foldLeft(true)((modZero, fn: (Int => Boolean)) => modZero && fn(x))
// divByAll: (fns: List[Int => Boolean])(x: Int)Boolean
val divBy3And5 = divByAll(List(divBy3,divBy5)) _
@noahlz
noahlz / simple-server.clj
Created April 25, 2014 05:50
Simple clojure server adapted from Clojure Cookbook that runs forever rather than exiting after reading the first line.
(ns hello.core
(:require [clojure.java.io :as io])
(:import [java.net ServerSocket]))
;; Server
(defn receive-msg [socket]
(.readLine (io/reader socket)))
(defn send-msg [socket msg]
(let [writer (io/writer socket)]
@noahlz
noahlz / scala-stuff.md
Last active August 29, 2015 14:00
A friend asked what I thought about Scala after coding it for about 6 months. Here's my reply:

Scala can be a little obtuse. Yesterday I encountered something like this:

def foo(bar: Bar): Option[Bazz => Buzz => Blah]

It's a function that takes Bar and returns an Option boxing a function that takes a Buzz and returns a Blah. I think some clarifying parenthesis are in order, and probably should be required by the compiler.

When you see something like this:

@noahlz
noahlz / FBounded.scala
Last active August 29, 2015 14:02
Learning about generic types that need to access their subtypes - in Scala
trait Color {
def name: String
}
abstract class PrimaryColor(val name: String) extends Color
case object Red extends PrimaryColor("Red")
case object Blue extends PrimaryColor("Blue")
case object Yellow extends PrimaryColor("Yellow")
trait HasColors {
@noahlz
noahlz / runbook-sketch.md
Created August 5, 2014 16:01
Thoughts on what goes in a runbook

Here's my idea of what goes in a run book for an application:

  • On which servers it is installed
  • Databases to which it connects (externally managed, not embedded)
  • how to start/stop, i.e. actual command line or script to execute
  • Scheduled batch jobs / EOD processes. Not the actual schedule, but when they generally run (EOD, overnight, etc)
  • Where to find log files
  • How to verify that it's actually running
  • A screen shot of the login page and one or two application pages is helpful.
@noahlz
noahlz / production-ready.md
Last active August 29, 2015 14:05
Thoughts on baseline requirements for deploying a server applicaiton to production.

Operations Team should not deploy a new software application to production unless the Development Team complies with the following minimum requirements:

Software Requirements

  • Packaging: the application must conform to conventions for configuration, directory structure and run scripts:

    • Configuration
    • Deployment Build
    • Run script
  • Reference Configuration: The reference configuration file included in the package must:

@noahlz
noahlz / SalatSandbox.scala
Last active August 29, 2015 14:07
Salat Sandbox
package noahlz
import com.novus.salat._
import com.novus.salat.global._
import com.novus.salat.grater
import scala.util.control.NonFatal
case class Data(name: String, datums: Vector[Double])
case class MaybeData(name: String, datums: Vector[Option[Double]])
case class Datum(d: Option[Double])
scala> val x = 1 :: 2 :: 3 :: Nil
x: List[Int] = List(1, 2, 3)
scala> val y = 1 :: 2 :: 4 :: Nil
y: List[Int] = List(1, 2, 4)
scala> x union y
res1: List[Int] = List(1, 2, 3, 1, 2, 4)
scala> res1.distinct
## Simple extension of the Chef tutorial for appending line(s) to the end of a cookbook
## Alternative to copying an entire cookbook just to add one line to a config file.
## (Apparently, partials are an alternative in Chef 11?
## http://stackoverflow.com/a/19167106/7507
file 'motd' do
content "hello chef\n"
end
ruby_block "ensure sig to end of file" do