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 / troubleshooting-with-jcmd.md
Last active May 31, 2019 13:47
Troubleshooting Production JVMs with jcmd

Troubleshooting Production JVMs with jcmd

jcmd is a powerful new tool introduced in Java 7. Along with jstack and jps, it should be in your go-to tool for solving production problems on the JVM. (Come to think of it, with this tool you don't really need jps anymore)

Here's an example session with jcmd:

$ ssh wopr.qa.corp.local
$ jcmd -l
34739 sun.tools.jcmd.JCmd -l
@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 / 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 / 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 / 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 / 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)]
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 / 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
@noahlz
noahlz / checklogs.py
Last active January 2, 2016 01:58
Little script adapted from paramiko simle example to check all your servers one at a time for an error condition. Not necessary if your servers use private key access.
# http://stackoverflow.com/questions/6012665/read-non-blocking-error-while-using-pxssh-ssh-module-for-python
# https://github.com/paramiko/paramiko/blob/master/README
# http://stackoverflow.com/questions/8491194/how-to-handle-socket-errors-as-exceptions-in-python-paramiko
import paramiko, base64, getpass, socket
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
user = getpass.getuser()
// Welcome to Scala version 2.9.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_15).
// Type in expressions to have them evaluated.
// Type :help for more information.
def foo(n: Int) = Some(n)
// foo: (n: Int)Some[Int]
List(1,2,3,4).map(foo(_))
// res2: List[Some[Int]] = List(Some(1), Some(2), Some(3), Some(4))