Skip to content

Instantly share code, notes, and snippets.

View juliofalbo's full-sized avatar
Looking for new technologies

Júlio Falbo juliofalbo

Looking for new technologies
View GitHub Profile
# The value of ssl_verify_callback is assigned to Net::HTTP#verify_callback
response = RestClient::Resource.new(
'https://localhost?q=Foo',
:ssl_client_cert => OpenSSL::X509::Certificate.new(File.read(ssl_client_cert)), # Part of the Client Certificate Validation
:ssl_client_key => OpenSSL::PKey::RSA.new(File.read(ssl_client_key), key_pass), # Part of the Client Certificate Validation
:ssl_ca_file => ssl_ca_file, # Part of the Client Certificate Validation
:verify_ssl => OpenSSL::SSL::VERIFY_PEER, # Part of the Client Certificate Validation
:ssl_verify_callback => lambda(&method(:ssl_verify_callback)) # Part of the Client Certificate Validation
).get
package main;
public class DeoptimizationExample {
public static void main(String[] args) {
for (int i = 0; i < 50000; i++) {
MyInterface myInterface;
if (i < 45000) {
// The first 45.000 executions will enter here
myInterface = new MyInterfaceImpl();
} else {
addPrometheusServiceDiscoveryService 'my_image_name' 8080 'my_container_prefix_' myservice
#
# Function responsible to add specific instances to a prometheus service discovery file
#
function addPrometheusServiceDiscoveryService {
IMAGE_NAME=$1
NUM_INSTANCES=$(docker ps | grep -c "$IMAGE_NAME")
PORT=$2
CONTAINER_NAME=$3
/**
* In this operation we are doing 0 conversions, since we are working only with primitive type
*/
private static void operationWithPrimitiveTypeFunctionInterface(){
long startTime = System.currentTimeMillis();
int[] array = initValues();
IntPredicate predicate = i -> i % 2 == 0;
@juliofalbo
juliofalbo / FunctionCompose.java
Created November 4, 2019 20:51
FunctionMethodCompose
default <V> Function<V, R> compose(Function<? super V, ? extends T> before) {
Objects.requireNonNull(before);
return (V v) -> apply(before.apply(v));
}
@juliofalbo
juliofalbo / AndThenMethod.java
Created November 4, 2019 20:47
andThenFuntion
default <V> Function<T, V> andThen(Function<? super R, ? extends V> after) {
Objects.requireNonNull(after);
return (T t) -> after.apply(apply(t));
}
@juliofalbo
juliofalbo / InheritanceFI.java
Created November 4, 2019 20:43
Inheritance Functional Interface
@FunctionalInterface
interface ParentInterface{
void parentAbstractMethod();
}
@FunctionalInterface
interface ChildInterface extends ParentInterface{
void parentAbstractMethod();
default void defaultChildMethod1(){
@juliofalbo
juliofalbo / FI.java
Created November 4, 2019 20:39
Functional Interface
@FunctionalInterface
public interface FunctionalI {
void abstractMethod();
default String defaultMethod() {
return "defaultMethod";
}
static String staticMethod() {
return "staticMethod";
interface ConcatStringInterface {
String concat(String param1, String param2);
}
class ConcatStringImpl implements ConcatStringInterface {
public String concat(String param1, String param2) {
return param1 + param2;
}
}
public class StaticMethods {
public static void main(String[] args) {
InterfaceWithStaticMethod impl1 = (text) -> System.out.println("Custom Message " + text);
impl1.printWithCustomMessage("Text");
InterfaceWithStaticMethod.print("Text");
}
}
interface InterfaceWithStaticMethod {
void printWithCustomMessage(String text);