This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
# | |
# Run parallel commands and fail if any of them fails. | |
# | |
set -eu | |
pids=() | |
for x in 1 2 3; do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.gubbns | |
import cats.data.{Kleisli, OptionT} | |
import cats.effect._ | |
import cats.implicits._ | |
import com.github.blemale.scaffeine.{Cache, Scaffeine} | |
import org.http4s._ | |
import org.http4s.headers._ | |
import org.http4s.server.Middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util | |
import com.sksamuel.avro4s.RecordFormat | |
import org.apache.avro.generic.GenericRecord | |
import org.apache.kafka.common.serialization.{Deserializer, Serde, Serializer} | |
object Avro4s { | |
implicit class CaseClassSerde(inner: Serde[GenericRecord]) { | |
def forCaseClass[T](implicit recordFormat: RecordFormat[T]): Serde[T] = { | |
val caseClassSerializer: Serializer[T] = new Serializer[T] { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case class User(id: Long, name: String, age: Int) | |
class DatabaseError extends Throwable | |
case object ErrorFindingUser extends DatabaseError | |
case object ErrorUpdatingUser extends DatabaseError | |
case class ErrorDeletingUser(msg: String) extends DatabaseError |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -e | |
# Formats any *.tf files according to the hashicorp convention | |
files=$(git diff --cached --name-only) | |
for f in $files | |
do | |
if [ -e "$f" ] && [[ $f == *.tf ]]; then | |
#terraform validate `dirname $f` | |
terraform fmt $f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 1) Edit the site's nginx config (/etc/nginx/custom-sites/site-name.conf) to add the lines below. | |
# 2) Reload nginx: sudo service nginx reload | |
server { | |
# existing conf here | |
# Nginx fix for the SAML 2.0 Single Sign-On plugin. | |
location ^~ /wp-content/plugins/saml-20-single-sign-on { | |
location ~ ^(?<script_name>.*?\.php)(?<path_info>/.*)?$ { | |
include fastcgi_params; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object Main extends App { | |
AvoidLosingGenericType.run() | |
AvoidMatchingOnGenericTypeParams.run() | |
TypeableExample.run() | |
TypeTagExample.run() | |
} | |
class Funky[A, B](val foo: A, val bar: B) { | |
override def toString: String = s"Funky($foo, $bar)" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.{IOException, File, ByteArrayOutputStream} | |
import org.apache.avro.file.{DataFileReader, DataFileWriter} | |
import org.apache.avro.generic.{GenericDatumReader, GenericDatumWriter, GenericRecord, GenericRecordBuilder} | |
import org.apache.avro.io.EncoderFactory | |
import org.apache.avro.SchemaBuilder | |
import org.apache.hadoop.fs.Path | |
import parquet.avro.{AvroParquetReader, AvroParquetWriter} | |
import scala.util.control.Breaks.break | |
object HelloAvro { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by dave @ beesandbombs.tumblr.com >:) | |
void setup() { | |
setup_(); | |
result = new int[width*height][3]; | |
result_ = new int[width*height][3]; | |
} | |
int[][] result, result_; | |
float time; |