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
@nickcernis
nickcernis / mariadb-brew-macos.md
Created July 13, 2020 15:13
Install MariaDB with brew on macOS and fix the “access denied” issue

Attempting mysql -u root fails with Access denied for user 'root'@'localhost immediately after doing brew install mariadb and starting mariadb with brew services start mariadb.

To fix it (with MariaDB still running):

  1. sudo mysql then enter your Mac user password
  2. ALTER USER 'root'@'localhost' IDENTIFIED BY 'newrootpassword'; replacing newrootpassword with the password you wish to use for the MariaDB root user.
  3. Ctrl-C to exit mysql.

You should then be able to connect to MariaDB with mysql -u root -p, then entering the root password when prompted.

@matzegebbe
matzegebbe / ApiGatewayApplication
Last active May 27, 2021 22:38
SpringCloudGatewayLogging
public class ApiGatewayApplication {
private static final Logger LOGGER = LoggerFactory.getLogger(ApiGatewayApplication.class);
public static void main(String[] args) {
SpringApplication.run(ApiGatewayApplication.class, args);
}
@Bean
public RouteLocator customRouteLocator(RouteLocatorBuilder builder) {
@WeirdBob
WeirdBob / GatewayApplication.java
Created November 21, 2017 12:55
Spring cloud gateway response body modification
package examples;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAutoConfiguration
public class GatewayApplication {
@jklingsporn
jklingsporn / CompletableFutureCollector.java
Last active May 22, 2021 20:52
Converts a Stream<CompletableFuture<X>> to a CompletableFuture<List<X>>
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import java.util.function.BinaryOperator;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collector;
@pethaniakshay
pethaniakshay / FXMLDocument.fxml
Created June 1, 2017 05:17
Splash Screen in JavaFX using FXML
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.image.Image?>
<?import javafx.scene.image.ImageView?>
<?import javafx.scene.layout.AnchorPane?>
<AnchorPane fx:id="ap" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.60" xmlns:fx="http://javafx.com/fxml/1" fx:controller="splashscreen.FXMLDocumentController">
<children>
<ImageView fitHeight="300.0" fitWidth="442.0" layoutX="116.0" layoutY="50.0" pickOnBounds="true" preserveRatio="true">
<image>
@ariesmcrae
ariesmcrae / DBHelper.java
Created May 12, 2017 03:14
Amazon EC2 Systems Manager Parameter Store - get environment key/value pairs using AWS SDK Java
private static Map<String, String> parameterStore() {
final AWSSimpleSystemsManagement client = AWSSimpleSystemsManagementClientBuilder.defaultClient();
GetParametersRequest request = new GetParametersRequest();
request.withNames("driver", "host", "port", "schema", "username", "password").setWithDecryption(true);
GetParametersResult result = client.getParameters(request);
Map<String, String> store = new HashMap<>();
@owainlewis
owainlewis / Gzip.scala
Last active June 21, 2023 05:30
Gzip Scala
import java.io.{ByteArrayOutputStream, ByteArrayInputStream}
import java.util.zip.{GZIPOutputStream, GZIPInputStream}
import scala.util.Try
object Gzip {
def compress(input: Array[Byte]): Array[Byte] = {
val bos = new ByteArrayOutputStream(input.length)
val gzip = new GZIPOutputStream(bos)
@kermitas
kermitas / PriorityThreadsDispatcher.scala
Last active January 30, 2019 13:47
Akka dispatcher with configurable priority for created threads.
package akka.dispatch
import com.typesafe.config.Config
object PriorityThreadsDispatcher {
/**
* Configuration key under which int value should be placed.
*/
val threadPriorityConfigKey = "thread-priority"
}
@colestanfield
colestanfield / gist:fac042d3108b0c06e952
Created August 8, 2014 22:55
sbt-assembly merge strategy for aop.xml files
// Create a new MergeStrategy for aop.xml files
val aopMerge: MergeStrategy = new MergeStrategy {
val name = "aopMerge"
import scala.xml._
import scala.xml.dtd._
def apply(tempDir: File, path: String, files: Seq[File]): Either[String, Seq[(File, String)]] = {
val dt = DocType("aspectj", PublicID("-//AspectJ//DTD//EN", "http://www.eclipse.org/aspectj/dtd/aspectj.dtd"), Nil)
val file = MergeStrategy.createMergeTarget(tempDir, path)
@maxd
maxd / modena.css
Last active March 13, 2024 22:47
modena.css from JDK 10.0.1
/*
* Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*