Skip to content

Instantly share code, notes, and snippets.

@lloydmeta
lloydmeta / Transform.scala
Last active August 24, 2018 16:46
[Scala] Transforms one case class into another as long as the fields are a subset of the other via LabelledGeneric; Scastie link https://scastie.scala-lang.org/lloydmeta/ra0dvrV5Q2uxruQKoR020Q/2
@ import $ivy.{`com.chuusai::shapeless:2.3.3`}
import shapeless._, ops.hlist.Align, ops.hlist.SelectAll, SelectAll._
class Transform[T] {
// The fun stuff. Given an S, returns a T, if S has the right (subset of) fields
def apply[S, SR <: HList, TR <: HList](s: S)(
implicit
genS: LabelledGeneric.Aux[S, SR],
@jeroenr
jeroenr / CaseClassAvroSerde.scala
Created February 20, 2018 09:55
Example of case class serializer and deserializer for Avro
class CaseClassDeserializer[CC](isKey: Boolean)(implicit format: RecordFormat[CC]) extends Deserializer[CC] with Logging {
private val deserializer = new KafkaAvroDeserializer(null, Map(
AbstractKafkaAvroSerDeConfig.SCHEMA_REGISTRY_URL_CONFIG -> Config.tracktivity.kafka.connect.`schema-registry-url`,
KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG -> "false"
).asJava)
override def configure(configs: java.util.Map[String, _], isKey: Boolean): Unit = {}
override def close(): Unit = deserializer.close()

Thread Pools

Thread pools on the JVM should usually be divided into the following three categories:

  1. CPU-bound
  2. Blocking IO
  3. Non-blocking IO polling

Each of these categories has a different optimal configuration and usage pattern.

http://www.oreilly.com/data/free/files/2014-data-science-salary-survey.pdf
http://www.oreilly.com/data/free/files/2015-data-science-salary-survey.pdf
http://www.oreilly.com/data/free/files/Data_Analytics_in_Sports.pdf
http://www.oreilly.com/data/free/files/advancing-procurement-analytics.pdf
http://www.oreilly.com/data/free/files/ai-and-medicine.pdf
http://www.oreilly.com/data/free/files/analyzing-data-in-the-internet-of-things.pdf
http://www.oreilly.com/data/free/files/analyzing-the-analyzers.pdf
http://www.oreilly.com/data/free/files/architecting-data-lakes.pdf
http://www.oreilly.com/data/free/files/being-a-data-skeptic.pdf
http://www.oreilly.com/data/free/files/big-data-analytics-emerging-architecture.pdf
@fathergoose
fathergoose / bash-survival-guide.sh
Last active April 24, 2020 23:26
The bare essentials to shell navigation
# I have forked a much more complete cheat sheet, but is complete at the expense of being accessable
# You can find that bigger cheat sheet here https://gist.github.com/fathergoose/3fbc3b5f6c0ba3cbe367b18030b39aba
# things in <angleBrackts> are variables to be replaced for a spcific instance of the command
# Getting Help
man <command> # Read the man(ual) page entry for a given command (detailed help)
<command> --help # This *usually* prints a short summary of a command's options and arguments
# Directories
@AndyFaibishenko
AndyFaibishenko / A_README
Last active September 27, 2023 20:06
Example FIX to JSON mapper
This Gist contains an example of how to write a a FIX protocol parser using QuickFIX/J.
It also includes the XML data dictionary and a sample FIX message file with one OrderList message.
If you want to build/run this, you will need to link with QuickFIX/J and Jackson jars:
quickfixj-all-1.5.3.jar
mina-core-1.1.7.jar
slf4j-api-1.6.3.jar
log4j-1.2.15.jar
jackson-core-2.5.1.jar
jackson-databind-2.5.1.jar
jackson-annotations-2.5.1.jar
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active May 14, 2024 11:33
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'