Skip to content

Instantly share code, notes, and snippets.

View dalegaspi's full-sized avatar
🎓
BU S2 2022

Dexter Legaspi dalegaspi

🎓
BU S2 2022
View GitHub Profile
@dalegaspi
dalegaspi / winboot.md
Created April 5, 2020 01:42
Creating Bootable Win10 Disk

This is the most updated instructible for creating a bootable Windows 10 USB drive:

https://alexlubbock.com/bootable-windows-usb-on-mac

Not only does it creatively uses rsync it also has provided a workaround when install.wim exceeds 4GB (the maximum file size for a FAT32 FS which the thumb drive is formatted with)

@dalegaspi
dalegaspi / log.py
Created August 1, 2019 02:55
Python Logging with YAML configuration
import logging
import logging.config
import yaml
from pathlib import Path
# https://stackoverflow.com/a/52266636/918858
here = Path(__file__).parent
LOG_CFG = here/'logging.yaml'
@dalegaspi
dalegaspi / graphql_sangria_scala.md
Created June 7, 2019 13:08
Thoughts on GraphQL and Sangria

Thoughts on GraphQL and Sangria

I have recently implemented GraphQL as an enhancement to an existing REST microservice application (written in Akka HTTP Framework) and here are a few random thoughts:

  • Sangria certainly makes things easy to adapt GraphQL to most Scala projects. The way the resolvers are implemented are elegant and simple; e.g. there's no explicit way of different handling whether your resolve method is a Future[T] or just a value; it's treated the same in code.
  • Sangria can use existing case classes for the GraphQL objects, and provides macros to avoid boilerplate. However, there are a bunch of caveats and limitations; we are using scalaxb to generate our case classes from XSDs, and sadly these are not workable with the Sangria macros. Fortunately, with the awesome libray Chimney this makes it less painf
@dalegaspi
dalegaspi / apple_tv_4k_settings.md
Last active December 30, 2022 20:27
Apple TV 4K Settings with an A/V Receiver

UPDATE December 2022

**Unless you have an older Apple TV 4K and/or a TV that's not manufactured from the last 5 years or so, do NOT follow the instructions below.

With the newer 4K TVs and especially paired with the newer generation of AppleTV, leave the Dolby Vision ON and leave Frame Rate Matching OFF or you will have audio sync issues. Newer TVs are already smart enough to detect frame rate so no need to do any of the instructions below.**

Prologue

The most prevalent issues as of this writing when using an Apple TV 4K with an A/V receiver:

@dalegaspi
dalegaspi / from_intellij_to_emacs_scala.md
Last active March 17, 2019 17:12
Moving from IntelliJ to Emacs + ENSIME for Scala Development on MacOS

Moving From IntelliJ to Emacs ENSIME for Scala Development on MacOS

Preface

I have been dependent on the use of IntelliJ for most of my development tasks but unfortunately it has given me an abundant source of frustration: despite its recent updates and fixes, it has become progressively slow and a resource hog even with conservative use of plugins and fancy features, which sometimes gets in the way of productivity.

Over the last few months, I have been purposely avoiding IntelliJ for some simple code edits if I don't have to.

Now I wouldn't exactly say Emacs with ENSIME is walk in a park--far from it. If you've been spoiled with the convenience of what IntelliJ provides out of the box, I would say switching to a mostly text editor would be a challenging endeavor.

@dalegaspi
dalegaspi / ProtobufSupport.scala
Created February 25, 2019 20:47
A mixin trait for using PBDirect with Akka HTTP for Protobuf support
import akka.http.scaladsl.marshalling.{Marshaller, ToEntityMarshaller}
import akka.http.scaladsl.model.MediaType.{NotCompressible, applicationBinary}
import akka.http.scaladsl.model.{ContentTypeRange, MediaType}
import akka.http.scaladsl.unmarshalling.{FromEntityUnmarshaller, Unmarshaller}
import pbdirect._
/**
* This allows you to have a mixin trait for use with Akka HTTP endpoints that accept/return Protobuf.
* This has been patterned after https://github.com/hseeberger/akka-http-json and uses
* https://github.com/btlines/pbdirect for "proto-less" (i.e. no .proto schemas) serialization/
@dalegaspi
dalegaspi / logback.xml
Last active January 30, 2019 15:28
A minimal logback.xml file for clojure applications...with colors! 😝
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property name="LOGS" value="./logs" />
<appender name="Console"
class="ch.qos.logback.core.ConsoleAppender">
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
<pattern>%black(%d{ISO8601}) %highlight(%-5level) [%blue(%t)] [%blue(%contextName)] %yellow(%logger{36}): %msg%n%throwable</pattern>
</encoder>
</appender>
@dalegaspi
dalegaspi / spring_boot_zuul_finchley.md
Last active April 8, 2020 09:20
Spring Boot + Zuul Finchley Notes

Preface

Listen, if you want to use Zuul, the easiest path is just use the Spring Boot version. I'm not exactly a fan of Spring in general, but this is the only solution available that's the least painful. Recent release of Spring Cloud Gateway looks promising but I'm satisfied so far with Spring Boot + Zuul that I'm not that interested in evaluating Spring Cloud Gateway,

We are also talking about Zuul 1.x here. Zuul 2.x is a whole can of worms I'd rather not rant about here.

This applies to Finchley (2.x) from SR1 release (may apply to other releases but not guaranteed)

  • Re: using logback. The documentation says it's recommended to use logback-spring.xml in your classpath, but it doesn't work. You should actually use logback.xml or your logging configuration is not recognized at all. While at the subject, it is recommended not to use asynchronous logging at all. U
@dalegaspi
dalegaspi / scala_retrospective.md
Last active June 6, 2019 10:47
My First Project with Scala: What I've Learned

As my first major project using Scala hits production without too much of a hitch, I present a small list of notes that summarizes my experience with the language:

  • Learn to embrace functional programming. I learned this early on that while Scala is able handle object-oriented programming quite well, it's built with functional programming in mind. This means learning flatMap/map, immutables, et cetera.
  • Learn the thin cake pattern.
  • For every XML library available, there are about 3,781 JSON libraries available. If you're using XML a lot in your project, I feel that Java 8/10 is still easier.
  • Jackson is still king of JSON serialization. Is it the fastest? No. Is it the leanest? Not by a long shot. We used a lot of POJOs that rely on serialization, and we've tried a lot of JSON libraries, and while others are faster, they have soul-crushing limitations that were not present with Jackson.
  • blocking > no
@dalegaspi
dalegaspi / CompressionUtils.scala
Last active May 9, 2018 15:54
Simple wrapper object for various compression algorithms (GZip, LZ4, Snappy) using generics
import java.io.{ByteArrayInputStream, ByteArrayOutputStream, ObjectInputStream, ObjectOutputStream}
import java.util.zip.{GZIPInputStream, GZIPOutputStream}
import scala.util.Try
/**
* aped from https://gist.github.com/owainlewis/1e7d1e68a6818ee4d50e (gzip compression)
* and from https://stackoverflow.com/a/39371571/918858 (ser/deser from Array[Byte])
*/
object CompressionUtils {