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 / 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 / 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 / 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 / windows_10_boot_loop.md
Created June 15, 2020 14:21
Windows 10 Preparing Automatic Repair Infinite Loop Issue

This issue has happened to me recently and this happened after i rearranged the cables on my custom PC to make it look cleaner.

Windows will just get stuck into the spinning dots and after 2 hard reboots it will go into the "Prepare Automatic Repair" then goes blank not able to boots successfully and will not even go into Safe/Repair mode.

Trying to boot Windows via USB is also successful. Windows Installer will start really slow but eventually gets stuck in starting the actual install. Selecting the PC Repair option leaves you in this state.

After a couple of hours troubleshooting, it turns out that the cable to one of the secondary SATA drives (NVMe is used as primary drive) isn't plugged in completely (most likely got dislodged while I was rearranging the cable as it's only held on by friction). Once i plug it in again, Windows has booted up successfully.

**TLDR: Windows 10 won't boot when one of the secondary SATA drives isn't plugged in correctly...make sure all SATA drives are plugged in pro

@dalegaspi
dalegaspi / DynamicPostTransformFilter.java
Last active August 28, 2023 04:32
Spring Cloud Gateway Response Modification
package yeet;
import lombok.extern.slf4j.Slf4j;
import org.bouncycastle.util.Strings;
import org.reactivestreams.Publisher;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.NettyWriteResponseFilter;
import org.springframework.cloud.gateway.filter.OrderedGatewayFilter;
import org.springframework.cloud.gateway.filter.factory.rewrite.CachedBodyOutputMessage;
import org.springframework.cloud.gateway.filter.factory.rewrite.MessageBodyDecoder;
@dalegaspi
dalegaspi / ConvertHttpMethodFilter.java
Created April 22, 2021 23:11
Custom Spring Cloud Gateway to change HTTP Method In Flight
package yeet;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.http.HttpMethod;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@dalegaspi
dalegaspi / install_py_3_centos7.md
Created June 1, 2021 21:43
How to Install Python 3 on Centos 7

How to Install Python 3 on Centos 7

  1. yum -y update
  2. yum install -y python3

you now have python3.

@dalegaspi
dalegaspi / es6_arrow_functions.md
Last active June 8, 2021 17:04
Arrow Functions and the Road to Declarative Programming

Arrow Functions and the Road to Declarative Programming

Consider this data:

let tbl_hs_students = {
  headers: [
    "First Name",
    "Year",
    "House",
@dalegaspi
dalegaspi / vue_vs_react.md
Last active June 14, 2021 02:16
Vue vs React 2021

For me, the better choice Vue.js regardless of size of the project. And this can be explained succintly with three simple words: Two Way Binding.

When I began using JavaScript frameworks for dynamic UI, I started with the original AngularJS. It is the original framework that elegantly implemented two-way binding in an MVVM framework, where a model is bound to an element/elements. The original implementation didn't scale as well (i.e., there is severe page performance as you add more and more two-way bindings), but this was actually mitigated (to an extent) by the introduction of one-way binding construct in v1.5.

If this feature is so great, why do some developers hate it and even calling it anti-pattern? A few reasons I could think of, actually.

  • While VueJS (and the newer Angular 2.x) has addressed the performance issues plagued by two-way bindings in Angular 1.x, there is a tende
@dalegaspi
dalegaspi / flask_redis.py
Created June 16, 2021 23:22
Flask Redis PUT/GET Endpoints
r = redis.Redis(host='localhost', port=6379, db=0, decode_responses=True)
@app.route('/api/guestbook/message', methods=['POST', 'PUT'])
def api_put_message():
form_data = request.form
id = str(uuid.uuid4())
data = {
'ts': round(time.time() * 1000),
'id': id,
'email': form_data['email'],