Skip to content

Instantly share code, notes, and snippets.

View marcelocg's full-sized avatar

Marcelo Gonçalves marcelocg

View GitHub Profile

Proxmox configuration

Avoid suspend when closing lid

[ Source ]

In /etc/systemd/logind.conf, uncomment (or write if empty) the following lines:

[Login]
@marcelocg
marcelocg / UserRestControllerTest.java
Created June 5, 2021 13:54 — forked from ekswai/UserRestControllerTest.java
spring oauth2 rest template with client credentials grant sample
import org.junit.Test;
import org.junit.runner.RunWith;
import org.master.Application;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.IntegrationTest;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.security.oauth2.client.DefaultOAuth2ClientContext;
import org.springframework.security.oauth2.client.OAuth2RestTemplate;
import org.springframework.security.oauth2.client.token.grant.client.ClientCredentialsResourceDetails;
@marcelocg
marcelocg / gen_annotation.sql
Created November 8, 2019 11:08
Generate JPA annotations for each column of a given Oracle Table
set serveroutput on;
declare
nm_table varchar(100) := 'NOTA_FISCAL_HIST';
nm_nullable varchar(100);
begin
for r in ( select c.* from all_tables t
inner join all_tab_columns c
on c.TABLE_NAME = t.TABLE_NAME
where t.TABLE_NAME = nm_table
order by c.column_id

Configure a Recently Installed Linux

System Proxy Configuration

$ sudo nano /etc/profile
# Add username:password@ befor the IP address if you need authentication, e.g if using NTLM proxy
export http_proxy=http://192.168.146.1:3128 
export https_proxy=http://192.168.146.1:3128
@marcelocg
marcelocg / install_docker.md
Last active May 31, 2019 13:51
Install and configure Docker on Ubuntu

Ubuntu Docker Installation and Configuration

Install

$ sudo apt update

$ sudo apt install \
    apt-transport-https \
    ca-certificates \
    curl \
@marcelocg
marcelocg / psqlfix.sh
Last active November 30, 2016 23:22 — forked from fgrehm/psqlfix.sh
if [[ -z "$1" ]]; then
echo "No argument supplied. Usage: pgsqlconfig.sh <appname>"
exit 1
fi
if ! $(psql template1 -c 'SHOW SERVER_ENCODING' | grep -q UTF8); then
psql postgres -c "update pg_database set datallowconn = TRUE where datname = 'template0';"
psql template0 -c "update pg_database set datistemplate = FALSE where datname = 'template1';"
psql template0 -c "drop database template1;"
psql template0 -c "create database template1 with template = template0 encoding = 'UTF8';"
@marcelocg
marcelocg / install_java8.sh
Created July 17, 2016 18:26
Installs the Oracle Java 8 on Ubuntu
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer
# Save this content to /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla
[Re-enable hibernate by default in upower]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes
[Re-enable hibernate by default in logind]
Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes
@marcelocg
marcelocg / docker_utils.sh
Last active May 22, 2020 15:03
Useful docker command lines
# Stop all containers
docker stop $(docker ps -a -q)
# Remove all containers
docker rm $(docker ps -a -q)
# Remove all volumes
docker volume rm $(docker volume ls -q)
l=Lancamento.find(:all).collect{ |l| [l.data.month, l.valor]} #=> [[3, 100.0], [10, 321.54]]
l.transpose #=> [[3, 10], [100.0, 321.54]]