Skip to content

Instantly share code, notes, and snippets.

View massahud's full-sized avatar

Geraldo Massahud massahud

View GitHub Profile
@massahud
massahud / tolocalestring.js
Created December 14, 2016 11:53
Date to locale string in javascript
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
let year = 'numeric';
let month = '2-digit';
let day = '2-digit';
let hour = '2-digit';
let minute = '2-digit';
let second = '2-digit';
let hour12 = false;
let weekday = 'short';
let era = 'narrow';
@massahud
massahud / 0_reuse_code.js
Created December 14, 2016 11:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console

= under construction =

. git clone https://github.com/apereo/cas-overlay-template.git . copy etc/cas/config to /etc/cas/config . edit /etc/cas/config to point to your domain . mvn clean package . java -jar cas.war

@massahud
massahud / eclipselink.md
Last active October 28, 2021 13:16
Wildfly 10.1.0
@massahud
massahud / java_opts.md
Last active October 31, 2016 12:46
Profile JBoss 7 netbeans

Add to java opts:

-Djboss.modules.system.pkgs=org.netbeans.lib.profiler.server
@massahud
massahud / meteorc9.io.md
Last active September 16, 2016 12:28
Meteor c9.io

Meteor on c9.io

Inside a node.js workspace:

Install: curl https://install.meteor.com/ | sh

To start meteor: meteor --port $IP:$PORT

import java.util.Arrays;
import java.util.List;
public class RadixSort {
public static List<String> sort(List<String> strings, int maxDigits) {
List<String> sorted = strings;
for (int i = maxDigits - 1; i > 0; i--) {
sorted = countSort(sorted, i);
}
return sorted;
@massahud
massahud / Portable Node.js andNPM on windows.md
Last active April 30, 2024 17:47
Portable Node.js and NPM on windows
  1. Get node binary (node.exe) from http://nodejs.org/download/
  2. Create the folder where node will reside and move node.exe to it
  3. Download the last zip version of npm from http://nodejs.org/dist/npm
  4. Unpack the zip inside the node folder
  5. Download the last tgz version of npm from http://nodejs.org/dist/npm
  6. Open the tgz file and unpack only the file bin/npm (without extension) directly on the node folder.
  7. Add the the node folder and the packages/bin folder to PATH
  8. On a command prompt execute npm install -g npm to update npm to the latest version

Now you can use npm and node from windows cmd or from bash shell like Git Bash of msysgit.

@massahud
massahud / gist:b7fd98dfeb5bdf54c83f
Last active August 29, 2015 14:01
Remove sonar duplicated last build
update sonar.snapshots old_snap set old_snap.islast=0
where islast=1
and exists (
select * from sonar.snapshots new_snap
where new_snap.created_at > old_snap.created_at
and new_snap.project_id = old_snap.project_id
and new_snap.islast=1
);
@massahud
massahud / batchjoinfetch.md
Last active May 17, 2018 17:12
JPA BATCH E JOIN FETCH

JPA Batch e Join Fetch

Quando uma entidade possui relacionamentos no JPA e a entidade do relacionamento é acionada, o provedor de persistência executa um select no banco. Isso leva a um problema conhecido como ORM n+1, que ocorre quando n entidades é obtida e para cada entidade da lista precisamos acessar um relacionamento, o JPA executará a um select para obter a lista, e para cada elemento da lista executará um select, totalizando n+1 selects no banco. Este é um motivo de lentidão de páginas JSF que contém tabelas e listas que deveriam ser simples.

Colocar o relacionamento como EAGER não é uma solução correta, pois EAGER apenas informa que o relacionamento deve ser carregado, podendo o provedor fazer um novo select para cada relacionamento EAGER de uma entidade.

Existem duas soluções comuns implementadas em provedores de persistência para resolver este problema, JOIN FETCH e BATCH FETCH, que serão explicadas abaixo.

JOIN FETCH