Skip to content

Instantly share code, notes, and snippets.

View luizrobertofreitas's full-sized avatar

Luiz Roberto Freitas luizrobertofreitas

View GitHub Profile
@luizrobertofreitas
luizrobertofreitas / gist:dd680fe80efbfd49c7817935d0527d79
Created June 10, 2017 04:54
Connect with php to dockered mysql
This happen because selinux avoid db connections from the httpd server to the remote db server. To solve it you need to access your server trough ssh or just open a console if you have pretencial acces and do the follow:
You must check in the SELinux if the port 80 is managed in. You can check it typing # semanage port -l | grep http_port_t for list and check:
http_port_t tcp 443, 488, 8008, 8009, 8443, 9000
If you need to add the required port, just type:
# semanage port -a -t http_port_t -p tcp 80
@luizrobertofreitas
luizrobertofreitas / send-message-to-graylog
Last active October 24, 2017 01:20
Graylog linux shell command
echo "Hello Graylog, let's be friends." | nc -w 1 -u 127.0.0.1 9000
echo '{"version": "1.1","host":"example.org","short_message":"A short message that helps you identify what is going on","full_message":"Backtrace here\n\nmore stuff","level":1,"_user_id":9001,"_some_info":"foo","_some_env_var":"bar"}' | gzip | nc -u -w 1 commons-graylog001.azure.zup.com.br 12379
@luizrobertofreitas
luizrobertofreitas / java6 on fedora
Created August 4, 2018 17:32
Java 6 on Fedora error
When getting the error about libnsl.so.1
ln -s /usr/lib64/libnsl.so.2.0.0 /usr/lib64/libnsl.so.1
ln -s /usr/lib/libnsl.so.2.0.0 /usr/lib/libnsl.so.1
@luizrobertofreitas
luizrobertofreitas / run-update-alternatives.sh
Created August 4, 2018 17:34
Setting up java alternatives
#!/usr/bin/env python
import subprocess
import os
ALL_JDK_FOLDERS = ['jdk1.8.0_181', 'graalvm-ee-1.0.0-rc4', 'jdk-10.0.1', 'jdk-9.0.4', 'jdk1.7.0_80', 'jdk1.6.0_45']
BASE_FOLDER = '/opt/jdks'
DEFAULT_JDK_FOLDER = 'jdk1.8.0_181'
@luizrobertofreitas
luizrobertofreitas / change-jdk.sh
Created August 4, 2018 17:35
Script to change jdk based on update-alternatives
#!/bin/bash
alternatives --config java
alternatives --config javac
alternatives --config javaws
alternatives --config jconsole
alternatives --config keytool
alternatives --config java_home
@luizrobertofreitas
luizrobertofreitas / gist:f99c9589dc038868e756b70f790dd2c4
Created February 22, 2019 03:28
Wierd LocalDateTime when using spring-boot < 2.0.0
1. On pom.xml
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.9.8</version>
</dependency>
2. On application.properties
1. Viewing branches diff with meld:
https://stackoverflow.com/questions/2006032/view-differences-of-branches-with-meld
git config --global diff.tool meld
File by File:
git difftool master..devel
Directory view:
git difftool -d master..devel
@luizrobertofreitas
luizrobertofreitas / nginx.conf
Created May 10, 2019 13:32 — forked from morhekil/nginx.conf
Full request/response body logging in nginx
http {
log_format bodylog '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" $request_time '
'<"$request_body" >"$resp_body"';
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua '
@luizrobertofreitas
luizrobertofreitas / NodeJS10Dockerfile.centos7
Created July 29, 2019 17:38
NodeJS 10 Dockerfile for Openshift Jenkins Slaves
FROM openshift/jenkins-slave-base-centos7
USER root
RUN curl -skL -o nodejs-bin.tar.xz https://nodejs.org/dist/v10.16.0/node-v10.16.0-linux-x64.tar.xz && \
tar -xf nodejs-bin.tar.xz && \
mv node-v10.16.0-linux-x64 /opt/nodejs
RUN ln -sf /opt/nodejs/bin/node /usr/local/bin/node && \
ln -sf /opt/nodejs/bin/npm /usr/local/bin/npm && \
@luizrobertofreitas
luizrobertofreitas / mysql-docker.sh
Created August 12, 2019 14:23 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE