Skip to content

Instantly share code, notes, and snippets.

View rafaelszp's full-sized avatar

Rafael Pereira rafaelszp

View GitHub Profile
import { useState } from "react";
export const useInput = initialValue => {
const [value, setValue] = useState(initialValue);
return {
value,
setValue,
reset: () => setValue(""),
hooks: {
//;Got from https://www.baeldung.com/httpclient-ssl
@Test
public void givenAcceptingAllCertificates_whenHttpsUrlIsConsumed_thenException()
throws IOException, GeneralSecurityException {
TrustStrategy acceptingTrustStrategy = (cert, authType) -> true;
SSLSocketFactory sf = new SSLSocketFactory(
acceptingTrustStrategy, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
SchemeRegistry registry = new SchemeRegistry();
registry.register(new Scheme("https", 8443, sf));
ClientConnectionManager ccm = new PoolingClientConnectionManager(registry);
@rafaelszp
rafaelszp / JavaC.sublime-build
Created February 15, 2018 13:27 — forked from jfcalvo/JavaC.sublime-build
Sublime Text 2 Build System for Java (Compile and running)
{
"cmd": ["javac \"$file_name\" && java \"$file_base_name\""],
"shell": true,
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}
@rafaelszp
rafaelszp / update_ssl_centos.sh
Last active August 29, 2017 13:09
Update OpenSSL on Centos7
#!/bin/bash
#Credits to cuibonobo: https://gist.github.com/cuibonobo/f37f723d1ce77f68c5ddf324c8468da3
# You need this for your OpenSSL tests to pass later
yum install perl-core
# Grab the source for OpenSSL 1.1, which has the patch for CVE-2016-2107
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.0b.tar.gz
tar -zxf openssl-1.1.0b.tar.gz
cd openssl-1.1.0b
@rafaelszp
rafaelszp / jboss-deployment-structure.xml
Created June 19, 2017 19:09
Disabling hibernate and JPA subsystems in you application
<jboss-deployment-structure xmlns="urn:jboss:deployment-structure:1.2">
<deployment>
<exclude-subsystems>
<subsystem name="org.hibernate" />
<subsystem name="org.hibernate.validator" />
<subsystem name="jpa" />
</exclude-subsystems>
<exclusions>
@rafaelszp
rafaelszp / FunctionalBuilderTest.java
Created March 10, 2017 11:33
Using Java 8 with Builder Pattern
import java.util.function.Function;
import java.util.function.Supplier;
class Student {
private String name;
private String email;
public String getName() { return name;
}
public void name(String name) {
@rafaelszp
rafaelszp / ramdisk-linux.sh
Created November 22, 2016 16:08
Criando RAMDISK LINUX
#Criando RAMDISK LINUX
mkdir /tmp/ramdisk
chmod 777 /tmp/ramdisk
mount -t tmpfs -o size=256M tmpfs /tmp/ramdisk/
@rafaelszp
rafaelszp / Convert_Postscript_output_to_image.sh
Created November 22, 2016 16:00
Convert Postscript output to image
convert -density 300 +antialias -quality 100 std.ps std.jpg
@rafaelszp
rafaelszp / CURL_COM_COOKIES_AUTH.sh
Last active November 22, 2016 15:56
CURL_COM_COOKIES_AUTH
#REQUEST COOKIE
curl -b cookies.txt -c cookies.txt -X GET http://HOST:PORT/demo-app/api/hello
#Authenticating using cookies
curl -H "Content-type:application/x-www-form-urlencoded" -b cookies.txt -c cookies.txt -d "j_username=USER&j_password=PASSWORD" http://HOST:PORT/demo-app/j_security_check
public static void main(String[] args) throws Exception{
ClassLoader cl = Demo.class.getClassLoader();
URL stageConfig = cl.getResource("project-stages.yml");
Swarm swarm = new Swarm(false).withStageConfig(stageConfig);
logger = Logger.getLogger(Demo.class);
swarm.fraction(datasource(swarm));
swarm.fraction(logging());
swarm.start();
swarm.deploy(archive());
}