Skip to content

Instantly share code, notes, and snippets.

View daviddefco's full-sized avatar

David de Francisco daviddefco

View GitHub Profile
// Example of error in processing a flux (with a map) stops the subscription (Only prints 1)
Flux.range(1,6)
.map(integer -> {
if(integer % 2 == 0) {
throw new RuntimeException("odd number!");
} else {
return integer;
}
})
.subscribe(flux -> flux.subscribe(System.out::println, System.err::println));
@daviddefco
daviddefco / boot.sh
Created April 26, 2018 12:01
Boot bash script to launch SpringBoot executable JARs
#!/bin/bash
usage="boot <JAR file name> <start|stop|restart>"
startProcess() {
echo "Starting JAR ${jar_filename}"
process_pid=`pgrep -f "^java.*${jar_filename}"`
if [[ ${process_pid} ]]
then
echo "JAR is already running with PID ${process_pid}. Stop it before starting or restart it."
@daviddefco
daviddefco / typescript-observables.md
Last active April 4, 2017 15:29
Typescript examples working with Observables (React) in asynchronous computing

Handling Asynchronous Code with Observables

Packaging Asynchronous Requests to Extract More Details

There are situations where we make an asynchronous request to get a list of entities (albums in the example). For each album we need to send another asynchronous request to get more detail about the entity, so that we can transofrm the entity with more detailed data. From the design point of view the cleanes solution is to hold all the logic needed for that process in a service, and the controller will ideally subscribe to a single observer that delivers the enriched entity (the original entity+ further details for the second data request).

@daviddefco
daviddefco / full_linkedin_profile
Last active August 15, 2021 01:33
Code to get access to both basic and full linkedin profiles. You make one execution with the first code block to get token and token secret values and then can remove this code, assign values to variables and get the access_token directly
require 'oauth'
# api_key and api_secret values are got from the registration of your application in LinkedIn:
# http://developer.linkedin.com/
api_key = 'Your API Key'
api_secret = 'Your API Secret'
# access_token and token_secret are known after the first execution code block
access_token = 'The token we get below'
token_secret = 'The token secret we get below'