Skip to content

Instantly share code, notes, and snippets.

View ferrerojosh's full-sized avatar

John Joshua Ferrer ferrerojosh

View GitHub Profile
@ferrerojosh
ferrerojosh / application.yml
Created March 3, 2020 10:28
Keycloak AuthZ Policy Enforcer Spring Boot Configuration
server:
port: 3000
spring:
main.banner-mode: OFF
datasource:
type: com.zaxxer.hikari.HikariDataSource
url: jdbc:postgresql://${DB_HOST}:${DB_PORT}/${DB_NAME}
username: ${DB_USER}
password: ${DB_PASS}
@ferrerojosh
ferrerojosh / keycloak.provider.ts
Last active July 10, 2023 20:03
Keycloak v9.0.0 NestJS Resource Guard
import { FactoryProvider, Logger } from '@nestjs/common';
import Keycloak from 'keycloak-connect';
export const KEYCLOAK_INSTANCE = 'KEYCLOAK_INSTANCE';
export const keycloakProvider: FactoryProvider = {
provide: KEYCLOAK_INSTANCE,
useFactory: () => {
const keycloakConfig: any = {
realm: '',
@ferrerojosh
ferrerojosh / R2DBCIO.kt
Last active February 16, 2024 18:06
Simple r2dbc client wrapper using kotlin coroutines
import io.r2dbc.spi.*
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.reactive.asFlow
import kotlinx.coroutines.reactive.awaitFirst
import kotlinx.coroutines.reactive.awaitFirstOrNull
import kotlin.reflect.KClass
/**
* An R2DBC client that uses Kotlin coroutines.
*/
@ferrerojosh
ferrerojosh / LICENSE
Last active March 20, 2019 18:40
BRIBE A CHOCOLATE LICENSE
BRIBE-A-CHOCOLATE LICENSE
Copyright (c) $today.year Author
This software is conditionally proprietary. As long as this notice
is attached, you will not in any verbatim modify, or release the
software without permission from the author.
If you think the software is worth it, you may send an entire bag two
kilograms minimum of chocolates (in mass) to each personnel that
@ferrerojosh
ferrerojosh / ARCH_INSTALL.MD
Created June 11, 2018 06:08 — forked from yabbes/ARCH_INSTALL.MD
Installing Arch with GPT, LUKS, LVM and systemd-boot

Create bootable USB

dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync

Boot from USB and set prepare system

loadkeys <your-keymap>
@ferrerojosh
ferrerojosh / fix-infinality.md
Created June 9, 2018 17:14 — forked from cryzed/fix-infinality.md
A set of instructions on how to fix the harfbuzz + Infinality issue and restoring good-looking, Infinality-like font rendering.

Disclaimer: Please follow this guide being aware of the fact that I'm not an expert regarding the things outlined below, however I made my best attempt. A few people in IRC confirmed it worked for them and the results looked acceptable.

Attention: After following all the steps run gdk-pixbuf-query-loaders --update-cache as root, this prevents various gdk-related bugs that have been reported in the last few hours. Symptoms are varied, and for Cinnamon the DE fails to start entirely while for XFCE the icon theme seemingly can't be changed anymore etc.

Check the gist's comments for any further tips and instructions, especially if you are running into problems!

Screenshots

Results after following the guide as of 11.01.2017 13:08:

@ferrerojosh
ferrerojosh / AndroidWorkerInjection.kt
Created May 30, 2018 06:40
androidx workmanager injector temporary impl
import androidx.work.Worker
object AndroidWorkerInjection {
fun inject(worker: Worker) {
checkNotNull(worker, { "worker" })
val application = worker.applicationContext
if (application !is HasWorkerInjector) {
throw RuntimeException("${application.javaClass.canonicalName} does not implement ${HasWorkerInjector::class.java.canonicalName}")
}
@ferrerojosh
ferrerojosh / MyFragment.kt
Last active April 19, 2018 06:27
Random material color
class MyFragment : Fragment() {
private fun randomMaterialColor(typeColor: String): Int {
var returnColor = Color.GRAY
val arrayId = resources.getIdentifier("mdcolor_$typeColor", "array", activity!!.packageName)
if (arrayId != 0) {
val colors = resources.obtainTypedArray(arrayId)
val index = (Math.random() * colors.length()).toInt()
returnColor = colors.getColor(index, Color.GRAY)
colors.recycle()
@ferrerojosh
ferrerojosh / md-sidenav-splitter.directive.ts
Last active June 8, 2017 05:14
A quick splitter control for angular material sidenav for Angular 2/4
import { AfterViewInit, ContentChild, Directive, ElementRef, Input, Renderer2 } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { MdSidenav } from '@angular/material';
@Directive({
selector: '[mdSidenavSplitter]'
})
export class MdSidenavSplitterDirective implements AfterViewInit {
@ContentChild(MdSidenav, {read: ElementRef}) sidenavRef: ElementRef;
@Input() splitterWidth = 10;